patternMinor
TeX preamble for theses and short books
Viewed 0 times
booksshortpreamblethesesfortexand
Problem
I recently joined the tex community and had quite a fun week texing. (I migrated this question to codereview, as it seems to be the better place for code-review samples). The result is some layout/format I would like to use for future theses/small-books. I did host the the whole thing here, and as others might like to contribute/pull I just set up a git rep. The small readme and introductory stuff is put inside the
I used the latest TeX 3.14159265 (TeX Live 2015) with texstudio under ubuntu 14.04.
A precompiled .pdf is included to have a quick peek,
Furthermore it is opensource licensed opensource.org/licenses/BSD-3-Clause. What do think about it so far, what needs to be improved? I appreciate any suggestions. Does it cross compile, also under windows?
As the code should be part all be on the platform itself I will post the main file (which includes all the important preamble statements)
```
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% My book_template1 v0.1 for LaTeX %
% %
%INSTALL %
% TeX-Distribution TeXLive 3.14159265 (TeX Live 2015), (alternative: MiKTeX)
% Compiler: pdfLaTEX (alt.: XeLaTeX, LuaLaTeX; might need slight adjustments)
% TexLive (rec.: zip) 1. files -> tug.org/texlive/acquire-netinstall.html
% (During the perl script run: [x] create symlinks to standard directories)
% 2. docs -> tug.org/texlive/doc/texlive-en/texlive-en.html
% TeXstudio/maker (for some GUI) -> texstudio.org
% 1. set default compiler: txs:///pdflatex | txs:///biber | txs:///pdflatex (advanced options)
% 1. make sure TeXstudio fin
0_main_layout.tex. I used the latest TeX 3.14159265 (TeX Live 2015) with texstudio under ubuntu 14.04.
A precompiled .pdf is included to have a quick peek,
Furthermore it is opensource licensed opensource.org/licenses/BSD-3-Clause. What do think about it so far, what needs to be improved? I appreciate any suggestions. Does it cross compile, also under windows?
As the code should be part all be on the platform itself I will post the main file (which includes all the important preamble statements)
```
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% My book_template1 v0.1 for LaTeX %
% %
%INSTALL %
% TeX-Distribution TeXLive 3.14159265 (TeX Live 2015), (alternative: MiKTeX)
% Compiler: pdfLaTEX (alt.: XeLaTeX, LuaLaTeX; might need slight adjustments)
% TexLive (rec.: zip) 1. files -> tug.org/texlive/acquire-netinstall.html
% (During the perl script run: [x] create symlinks to standard directories)
% 2. docs -> tug.org/texlive/doc/texlive-en/texlive-en.html
% TeXstudio/maker (for some GUI) -> texstudio.org
% 1. set default compiler: txs:///pdflatex | txs:///biber | txs:///pdflatex (advanced options)
% 1. make sure TeXstudio fin
Solution
To answer your questions in turn:
Any package incompatibilities? Import ordering?
Not that I can see, but you’re importing a lot of packages – 44 at a rough count. In general, I prefer to keep a small number of packages in my base file, and include them as-required. This reduces the likelihood of a package clash in a document (hyperref is one common culprit, etoolbox is another).
Only taking dependencies (packages) you need is generally good programming practice:
Does it work on Windows?
No idea, sorry. I don’t have a Windows installation of TeX to hand.
Any other comments?
-
There are lots of comments, but they only describe what the package or command is doing. They don’t explain why they’re in this document/template. This makes it very hard to break out into smaller chunks, delete code later, and so on. Tell me how this relates to your document style – what effect is it achieving? Why are you going for that effect?
-
Your document is littered with
-
I’d be tempted to break up this preamble into lots of smaller chunks, which can be enabled or disabled on a per-document basis. Two ways you could do this:
That helps cut down the unnecessary dependencies (see above), makes it easier to refactor just a small part of the style file without affecting the rest, and makes it easier to reuse this in non-book documents. For example, your chapter code will just error in the article class.
Plus, it means you can change the style for every document at once, rather than having to edit lots of documents individually.
-
It’s not clear why you’re defining the
-
All the packages you have, and you don’t include
Any package incompatibilities? Import ordering?
Not that I can see, but you’re importing a lot of packages – 44 at a rough count. In general, I prefer to keep a small number of packages in my base file, and include them as-required. This reduces the likelihood of a package clash in a document (hyperref is one common culprit, etoolbox is another).
Only taking dependencies (packages) you need is generally good programming practice:
- Less work when you’re setting up a fresh build environment.
- Less chance of packages changing under you and breaking, and/or going away.
- Faster compilations – in this case, that’ll be the time it takes for LaTeX to produce the final PDF.
- Reduced risk of unaffected side effects or clashes between packages.
Does it work on Windows?
No idea, sorry. I don’t have a Windows installation of TeX to hand.
Any other comments?
-
There are lots of comments, but they only describe what the package or command is doing. They don’t explain why they’re in this document/template. This makes it very hard to break out into smaller chunks, delete code later, and so on. Tell me how this relates to your document style – what effect is it achieving? Why are you going for that effect?
-
Your document is littered with
% TOSET comments. It would be nicer if they were pulled into one section, right at the top of the file, so they can all be edited at once. It reduces the chance that somebody will miss one while going through the document.-
I’d be tempted to break up this preamble into lots of smaller chunks, which can be enabled or disabled on a per-document basis. Two ways you could do this:
- Put it in a style
.styfile, with appropriate flags for the different options
- Put the chunks in small
.texfiles, and\inputthem on-demand.
That helps cut down the unnecessary dependencies (see above), makes it easier to refactor just a small part of the style file without affecting the rest, and makes it easier to reuse this in non-book documents. For example, your chapter code will just error in the article class.
Plus, it means you can change the style for every document at once, rather than having to edit lots of documents individually.
-
It’s not clear why you’re defining the
\onetwoside macro immediately before passing it to the book class. Why not just pass oneside correctly? It’s less confusing, and doesn’t create the odd sight of a macro being in class options.-
All the packages you have, and you don’t include
booktabs. Loathe as I am to recommend more packages, this makes really nice-looking tables, and your example document does include so. Use it.Context
StackExchange Code Review Q#125213, answer score: 6
Revisions (0)
No revisions yet.