0

I'm trying to learn how to programming in Latex. I want to make an if-else-statement. What I will do is something like this:

\def\x{2}
{
\if x =2
Yes
\else
no
\fi
}

But it doesn't work exactly how I imagine it would be. Any suggestions how to fix this minimal example?

Mico
  • 506,678
Simon
  • 157
  • 2
    After \def\x{2}, use \ifnum\x=2Yes\else no\fi. – Mico Sep 17 '15 at 18:26
  • 3
    \ifnum\x=2 Yes\else No\fi a space after the two. If you have the code in different lines, the end of line acts as the space. – Manuel Sep 17 '15 at 18:28
  • This is effectively Plain TeX usage and not LaTeX, but works there too, of course, if the correct syntax is used, of course –  Sep 17 '15 at 18:48
  • Arh thanks. What I want to do is to make an if-else statement i the preamble. It could be if x=2 \geometry{left=3.0cm , right=3.0cm , top=4cm , bottom=4cm} else \geometry{left=6.0cm , right=2.0cm , top=3cm , bottom=2cm} end

    Can this be done ?

    I can only make an if-else statement between the begin and end document.

    – Simon Sep 19 '15 at 11:24

0 Answers0