I write a document with the book
class and have a file (mainstyle.sty
) with a number of packages that I use (pdfx
, lipsum
, placeins
, etc\ldots
).
I recently started playing around with tufte-book
and got several warnings, errors and unpleasant messages. Got my hands on it, but I realise that it will take time to tune it little by little. I would like to switch classes easily and load the corresponding packages and options easily.
The main issue here is that the class tufte-book
loads several packages previously, and thus my file crashes if I just change the class on the fly.
Right now, what I have in master.tex is:
%\documentclass[a4paper]{tuftebook}
\documentclass[12pt,a4paper]{book}
\usepackage{./inc/mainstyle}
\begin{document}
text text text
\end{document}
My idea now is to split mainstyle.sty
in two files and use a mixture of conditionals and \PassOptionsToPackage
(inspired by these two questions). The idea would be to have a parameters.sty
file and a load.sty
file, with the main document modified like:
\input{./inc/parameters}
%\documentclass[a4paper]{tuftebook}
\documentclass[12pt,a4paper]{book}
\input{./inc/load}
\begin{document}
text text text
\end{document}
Then I'd have something like:
%parameters.tex ---------
\PassOptionsToPackage{pdftex,pdfa,hidelinks}
and:
%% load.tex ------------
\makeatletter
\@ifclassloaded{book}{
\usepackage{hyperref}
}{
\@ifclassloaded{tufte-book}{
% hyperref was already loaded
}
}
\makeatother
This is roughly the same that is proposed in this other question, right?
However, it feels cumbersome and I don't know if I'm just messing things around. Also, my understanding of conditionals/macros and such is still very limited.
Is this the right way to go?
nohyper
which is a splendig idea. It should be used by everyone ashyperref
should NEVER be loaded by a freaking class file. It cuts off YOUR control.nohyper
tip, I have it in my code already.filehook
package to patch/repatch macros after a package has been loaded, but that's just kicking the can farther down the road in some cases.\@ifclassloaded
and\@ifpackageloaded
?