Knowledge Collection
This is supposed to be a compact, searchable collection of the most important stuff I had to during my physics studides, because it would be a shame if I forget it all!
LaTeX Guideline
Here is some info to help myself remember why I did things the way I did.
In general, most content should be written with macros, so that the behaviour can be changed later.
fqname
All translation keys and LaTeX labels should use a structured approach:
<key type>:<partname>:<section name>:<subsection name>:<...>:<name>
The <partname>:...:<lowest section name>
will be defined as fqname
(fully qualified name) macro when using the \Part
, \Section
, ... macros.
<key type>
should be
- equation:
eq
- table:
tab
- figure:
fig
- parts, (sub)sections:
sec
Reference functions
Functions that create a hyperlink (and use the translation of the target element as link name):
\fqSecRef{}
\fqEqRef{}
Multilanguage
All text should be defined as a translation (translations
package, see util/translation.tex
).
Use \dt
or \DT
or the the shorthand language commands \eng
, \Eng
etc. to define translations.
These commands also be write the translations to an auxiliary file, which is read after the document begins.
This means (on subsequent compilations) that the translation can be resolved before they are defined.
Use the gt
or GT
macros to retrieve translations.
The english translation of any key must be defined, because it will also be used as fallback.
Lower case macros are relative to the current fqname
, while upper case macros are absolute.
Never make a macro that would have to be changed if a new language was added, eg dont do
% 1: key, 2: english version, 3: german version
\newcommand{\mycmd}[3]{
\dosomestuff{english}{#1}{#2}
\dosomestuff{german}{#1}{#3}
}
\mycmd{key}{this is english}{das ist deutsch}
Instead, do
% [1]: lang, 2: key, 2: text
\newcommand{\mycmd}[3][english]{
\dosomestuff{#1}{#2}{#3}
}
\mycmd{key}{this is english}
\mycmd[german]{key}{das ist deutsch}