I am writing a novel and I would like to create a data structure to hold character attributes and be able to reference the values.

I looked into creating custom glossaries, bibtex and datatool structure but I wasn't able to find a suitable method. I would much prefer not creating custom commands and using native latex available functionality.


    title = {Emma},
    dateofbirth = {1995-05-10},
    eyecolor = {brown}

Emma her eye colour is \ref{emma:eyecolor}.
  • 1
    "Standard LaTeX" does not have a function to do that out of the box. You will have to resort to packages. I'm not sure if biblatex is your best bet here, but since you tagged your question biblatex, let me say that you can define new data types as described in tex.stackexchange.com/q/175776/35864 and that you can extract specific data from entries as shown in tex.stackexchange.com/q/207591/35864.
    – moewe
    Commented Jul 2, 2023 at 15:37
  • This could be a solution, I tried it but cant get the MWE working. All I see is [se:l3help] on the page, not its contents.
    – Rien
    Commented Jul 2, 2023 at 15:51
  • 1
    Do you really need to use external tools to manage this? It's easy to set up a data structure like your example using expl3 property lists. Also it's not too difficult to parse JSON input in LuaTeX. See Ways to parse JSON in LaTeX?.
    – Alan Munn
    Commented Jul 2, 2023 at 16:12
  • I have not used expl3 before and not sure how it works, I dont want to make it too complicated, not for myself but also others
    – Rien
    Commented Jul 2, 2023 at 16:16
  • 1
    If you want to use the biblatex solution you need to compile your document with Biber. See tex.stackexchange.com/q/63852/35864 for background and tex.stackexchange.com/q/154751/35864 for help on getting your editor to run Biber for you. I don't necessarily think biblatex is the best approach here. You don't need all features of bibliographies and citations and the overhead is probably not worth it here.
    – moewe
    Commented Jul 2, 2023 at 19:08

1 Answer 1


I agree with others that a bibtex database probably is not the best way. One alternative that you may explore is put the data in a R data frame, that can be easily integrated with LaTeX text in several ways.

Here a MWE showing only some of these ways:

(note: if you do not have idea of what is R/knitr, save the file as mwe.Rnw to compile it with RStudio, or alternatively save it as mwe.Rtex to compile it on line in Overleaf.)



df <- data.frame(
    name=c("Negan","Rick Grimes","Maggie Greene"),
    date = c("1995-05-10","1995-05-13","2005-05-13"),
    eyecolor = c("brown","blue","green"),
    rol = c("evil","hero","survivor"),

row.names(df) <-  c("negan","rick","maggie") # nick names  

print(xtable(df, caption="Example characters to start walking, but alive."), booktabs=TRUE)

df$date <-  as.Date(df$date)


I am 
\Sexpr{df["negan","name"]}. Main characters are 
\Sexpr{df$name[1]} have  
\Sexpr{df$eyecolor[1]} eyes and born in 
\Sexpr{format(df$date[1], format="%Y")} 
and he is the 
\Sexpr{df["negan","rol"]}, whereas 
\Sexpr{df["rick","name"]} is the  
\Sexpr{df["rick","rol"]} of  
\Sexpr{df["rick","eyecolor"]} eyes and born only 
\Sexpr{df$date[2]-df$date[1]} days later. 
\Sexpr{df["maggie","name"]} was roughly 
\Sexpr{round((df$date[3]-df$date[2])/365.25,0)} years younger and have  
\Sexpr{df[3,3]} eyes. She is a 
\Sexpr{df["maggie","rol"]} survivor of the zombie apocalypse. 
Each character kill an average of
\Sexpr{round(mean(df$zombies),0)} zombies.

Not the answer you're looking for? Browse other questions tagged .