3 ms·
>I now have 10+ conditional flags in my book: ifPG13, ifPRINT, ifEBOOK, ifEREADER, etc. I'm looking to add more, but the basic \ifthenelse macro in LaTeX won't
by grayclhn 12y ago
>I now have 10+ conditional flags in my book: ifPG13, ifPRINT, ifEBOOK, ifEREADER, etc. I'm looking to add more, but the basic \ifthenelse macro in LaTeX won't be enough...
Makefiles can be your friend... in the file `Makefile` put
.PHONY: all pg13 print ebook ereader
all: pg13 print ebook ereader
pg13: book-pg13.pdf
book-pg13.pdf: mainfile.tex
pdflatex "\setstuffforethisversion\input{mainfile}"
print: book-print.pdf
[etc...]
Then type `make print` or `make ebook` etc at the command line. (This version is almost certainly too simplistic, but I hope the point is clear.)
- ivan_ah 12y agoHm... reading-in the src from the command looks a little brittle, but it's a must try. The makefile will also help with the need to compile 3 times with latex.
- grayclhn 12y agoIt's definitely brittle, but it's brittle along a dimension that usually doesn't change much over the course of the project (paper, book, etc). If you have automatically generated images or tables the benefits can be huge. `latexmk` solves the "compile many times" problem, and can monitor for changes to the source file in the background.