1

The Greek Ministry of Education allows two different sizes for our textbooks, namely the small size (17 cm X 21 cm) and the large size (namely 21 cm X 25 cm) .. I define both sizes using the geometry package - for example to get the large size I call the package as

\usepackage[a4paper,
            inner=1.55cm,
            outer=1.55cm,
            left=1.55cm,
            right=1.55cm,
            top=1.58cm,
            bottom=1.58cm,
            headsep=4mm]{geometry}

and a similar call is used for the small size .. I wonder if it is possible to parametrize the process in the way we do in in programming languages, namely, to define a variable bookSize and two constants SMALL and LARGE and write a code in the form

if bookSize=SMALL call geometry package with values for 'small' size
if bookSize=LARGE call geometry package with values for 'large' size

If LaTeX allows such a coding, where can I find all the relevant documentation to study this stuff? thanks a lot .... Athanasios

3
\documentclass{book}

% giving value to a variable
\def\bookSize{SMALL}%

% using some conditionals
\makeatletter
\def\ATH@SMALL{SMALL}%
\def\ATH@LARGE{LARGE}%

\ifx\bookSize\ATH@LARGE
\usepackage[a4paper,
            inner=1.55cm,
            outer=1.55cm,
            left=1.55cm,
            right=1.55cm,
            top=1.58cm,
            bottom=1.58cm,
            headsep=4mm]{geometry}
\fi
\ifx\bookSize\ATH@SMALL
\usepackage[a5paper,% or what ever
            inner=1cm,
            outer=1cm,
            left=1cm,
            right=1cm,
            top=1cm,
            bottom=1cm,
            headsep=3mm]{geometry}
\fi
\makeatother


\begin{document}
Hello world
\end{document}

You will find relevant documentation in http://www.eijkhout.net/texbytopic/texbytopic.html. Follow from there the link to the bitbucket site for free download. And of course in the TeXBook (not free).

Now of course, there are many LaTeX packages embedding the core TeX primitives into supposedly user-level interface. These packages correct to some extent the initial perspective of LaTeX from Leslie Lamport's book (not free) which is not really oriented towards "programming LaTeX" (I mean at user level of course).

LaTeX3 project has developed extensive approach inclusive of user-level and package author-level. I guess you should check xparse documentation (free...) and of course explore more at https://ctan.org/tex-archive/macros/latex/contrib/l3packages which contains already usable very significant modules. Edit: some more links need to be added like regex and, ah I was looking for this one l3kernel

  • texdoc topic should open a pdf viewer with the TeX by Topic pdf. – user4686 Oct 1 '17 at 9:43
  • the % in my answers are not really needed: they are there to comment out the rest of the line, which means avoiding a space token from the end-of-line processing by TeX. But such a space token would cause no harm in those locations anyhow. – user4686 Oct 1 '17 at 9:56
  • remark: there is an \else in TeX but there is no \elif. Which is a pity because it would have simplified a great many things related to expansion (but a priori one would have one needed \elifx, \elifnum, \elifdim, .., a bunch of them -- I did not think it over at all -- and this multiplication could have been deterrent to their introduction; possibly e-TeX could have done so) – user4686 Oct 1 '17 at 9:57
  • Thanks a lot !! i will study all this info .. i hope to contribute to the forum when i reach and expert level – Athanasios Margaris Oct 1 '17 at 11:30
  • TeX by Topic (and of course TeXBook) give excellent ressources for learning TeX. It is a macro expansion language. It handles spaces in a very special manner, because they have both typesetting significance and syntactic significance. With LaTeX, you can use packages etoolbox, xstring, ... but it is very good to be well-versed in core material from TeXBook/ TeX by Topic. And it is indispensable to become acquainted with the e-TeX extensions which however have no general public documentation although incoporated since 2004 by default in pdftex (from TeXLive). texdoc etex. – user4686 Oct 1 '17 at 12:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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