1

I developed a LaTeX template for my work in recipe development. I work on multiple, new, recipe ideas weekly, and the task of picking through the template to change titles, image file names, ingredients, instructions, references, and my development notes is quite tedious, and too often results in the accidental addition of deletion of important syntax, requiring more time to locate and fix. But what if I could enter my changes in a simple text file and use a programming language to "put it in" my Latex template for typesetting? That would be a significant improvement to my work process. My programming days are a long way behind me, but I'm willing to learn, as I expect to be doing this for the next few years. Any reason this won't work, and any suggestions for programming languages to try?

Many thanks.

6
  • 3
    you might want to look at pandoc, you could write the document in markdown (like this site) and pandoc will turn it into latex (or Word) or various other things Apr 23, 2021 at 18:25
  • you could also get latex to read your plain text file directly, if you prefer but depends how many instructions you need in the "plain text" how easy that would be. Apr 23, 2021 at 18:26
  • Thank you, David Carlisle, I'll check out pandoc.
    – cpg2020
    Apr 23, 2021 at 18:51
  • So I don't think pandoc will accomplish my goal. Restating: I'm thinking of a program that opens a txt file containing the recipe content (no latex commands), parses out the individual components (title, ingredients, instructions, etc), and wraps the desired (according to the template I created) LaTeX code around it. I compile that tex file in LaTeX and out pops the pdf recipe.
    – cpg2020
    Apr 24, 2021 at 0:10
  • That is basically a description of what pandoc does, but where the "plain text" is markdown eg a title is ## my title here , if you want a custom input syntax ("parse plain text" doesn't really mean anything) you must specify some grammar so you can know what is a title and what is an ingredient, then you need a custom parser but you could use any language, including tex for that or python or perl or lua Apr 24, 2021 at 7:16

1 Answer 1

1

You can use the csvsimple package.

I solved a similar problem (creating a conference's program with abstracts from an external csv file) using the \csvreader command.

In my case, I needed to import several lines from the csv (one line per speaker), but you can have a one-line csv file with the fields you need.

Example:

CSV file:

greeting, pronom, type, farewell
{Hi}, {I}, {csv}, {Bye}

LaTeX main.tex:

\documentclass{article}
\usepackage{csvsimple}

\begin{document}

\csvreader[head to column names]{contents.csv}{}{%
\textbf{\greeting},\\
\\
This is a small paragraph \pronom did to show how to read external \type files. \\
\\
\farewell \\
}

\end{document}

Result:

enter image description here

1
  • This is a very interesting option CarLaTeX. I'll give it a try and let you know. Thank you.
    – cpg2020
    Apr 24, 2021 at 2:03

You must log in to answer this question.

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