TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created a file which provides convenient options to change the settings for all of my documents. For e.g.:

\def\BookFontRoman{Gentium Plus}
\def\BookFontCJK{Adobe Song Std}
\def\DisplayFootnotes{1} %1=yes, 0=no
\def\LongTitlePage{1} %1=yes, 0=no

Saved as settings.tex, this can be read through the use of \input{settings}. My documents also contain etoolbox if-then conditionals to check some values. However, I also use some BASH scripts to assist in the generation of some LaTeX code.

This has some benefits:

  • I can establish consistent settings for all of my documents.
  • I need not edit to critical source code to make these formatting adjustments.

Can you recommend a better way to store settings?

  • Is there a more simpler format for putting such information into a single file?
  • Is there a solution for allowing BASH scripts to also access this information or (if that is too difficult) access other information also stored later in the file (which is ignored by XeTeX)?
share|improve this question
You should keep the bash scripts separate unless you're doing something very unusual. Can you elaborate on what it is your scripts are doing? There is probably a LaTeX equivalent. Otherwise, you can bundle all the TeX stuff into your own .sty file and include it in your document with \usepackage. – qubyte Nov 23 '11 at 8:24
up vote 6 down vote accepted

Instead of using a .tex file I would use a package or wrapper class like shown in the answers to "Many documents, same preamble".

bash syntax is very different from LaTeX syntax so I would not try to parse the LaTeX settings with a bash script. But you may add a command to your package or wrapper class to write a .sh file with all the settings. bash could then write a minimal document and run LaTeX to this, to generate the .sh file, e.g.

% example package
\RequirePackage{etoolbox}% because you're using new booleans with etoolbox
% …
  \immediate\openout\bashsettings #1

The bash script may do

echo '\documentclass{minimal}\usepackage{mysetting}\writesettingto{mysettings.sh}\begin{document}\end{document}' > createsettings.tex
latex -interaction=batchmode createsettings.tex || exit -1
. mysettings.sh

You may extend this with a configuration file, e.g. mysettings.cfg that will be loaded at the end of your package, e.g.

\renewcommand*{\anothersetting}{Not OK}

And add line


At the end of mysetting.sty. So you don't need to edit the package (or wrapper class) to change settings of a project, but only put a mysettings.cfg into the project folder.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.