Context: I'm a university lecturer and therefore facing the same tasks whenever I prepare for a new semester. One of them is creating course material with LaTeX which includes a syllabus, slides for each meeting, a bibliography, and notes that I use while teaching (containing a schedule for each session, didactic objectives etc.). Right now I always create these documents as single files; I can use documents from a previous semester as templates, but I have to replace all the information for each document type at least once. This is why I came up with the idea that inspired my question:

Is there a possibility to have some sort of master document that contains relevant meta data that I can access from within other documents (e.g. create a beamer document for each session from a template with the titles, expand a short bibliographic reference within the on the syllabus document into a full entry based on a list of texts within the master document)? I am not talking about the import/export of a whole file but rather picking specific lines/paragraphs and copying them/creating new documents from them based on a routine/template. I thought about workarounds with Python but wanted to see if this could be done entirely with LaTeX first.

Edit/Addendum: To give you all an example: I plan my courses with pen & paper. When I'm ready to create documents, I always start with the syllabus. It contains titles, dates, brief descriptions, bibliographic references, information about the course as such etc. Then I create notes and slides for each session. There I copy some of the information from the syllabus at least twice (e.g. titles, dates, bibliographic data). I am looking for a way that allows me to create a master document where I store this information once so that I can generate notes, slides etc.

  • 1
    Yes it's possible. But I find this too abstract to give any meaningful answer.
    – user202729
    Oct 20, 2022 at 14:52
  • Thank you for your response and apologies for the lack of details! I tried to be more specific when it comes to my workflow right now in the original post
    – macright
    Oct 20, 2022 at 15:04
  • The following question might help with some parts of your question: Pass dynamic arguments to standalone files
    – dexteritas
    Oct 20, 2022 at 15:07
  • 1
    It might be helpful, if you make a minimal working example (MWE) with your master document and one or two documents that should use the data.
    – dexteritas
    Oct 20, 2022 at 15:25
  • Depending on the complexity of your data, you could put it all into a csv and use csvsimple to read the appropriate row. But a more specific example of what you're trying to do would be nice.
    – Teepeemm
    Oct 20, 2022 at 15:59

2 Answers 2


This is one of the problem that macros are the most helpful for.

One approach is to have a master file with boilerplate text saved in macro definitions, and then call these macros from within files for specific applications. So you have one file that defines commands like \NewDocumentCommand{\myname}{}{Prof. Jane Doe, PhD} and in your syllabus file you \input the master file in the preamble and then write \myname. I use this approach when I repeatedly need the same text, like stock statements on credit hour policy that the university requires in every syllabus. Just add \creditHourPolicy and it's done.

Another approach is to have a master file with dummy commands in it, and redefine those commands in a specific application. So the master file has the whole document structure but with placeholder commands, e.g.,

    \courseName \\
    \courseSemester \\
    \courseCredits \\

Then in the file for this course syllabus, you just define those commands, or redefine them: \NewDocumentCommand{\courseName}{}{\LaTeX{} 101} I use this approach when I repeatedly need the same formatting but with different contents (similar to how \maketitle is set up).

Better than option #2 would be to create commands with arguments for the variable text and put them in a class or package file. Then you have this:

% Table of course info. Arguments:
% #1 course name
% #2 course semester
% #3 course credit hours (optional: default 4.0)
\NewDocumentCommand{\courseInfo}{m m O{4.0}}{%

Then in the syllabus, write

\courseInfo{\LaTeX{} 101}{Fall 2022}[3.0]

You can combine these approaches, too. Just make sure you input the file with the definitions before you use the commands.

  • Thank you (and also thanks to every other user that commented on my question)! Your response is extremely helpful when it comes to (semi-)automated document generation!
    – macright
    Oct 20, 2022 at 15:51
  • @macright Happy to help - I would welcome your upvote! Oct 20, 2022 at 20:28

Maybe https://texfaq.org/FAQ-conditional is helpful? In addition to Python scripts, one can use a Makefile which offers an alternative way to specify dependencies in generating your output, which may be helpful if you also need to generate bibliographic references.

You must log in to answer this question.

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