11

How do I use to insert ifthenelse crop marks in Tikz. I want

ifthenelse{\printcrop=true}{\draw(0,0) -- ++(0,1);}{}

That is, if yes, make a drawing, else but do nothing.

And yet, where I can choose the option true or false?

10

You can define your own if-switch using \newif\ifyourname and then use \yournametrue and \yournamefalse to set it to true or false, respectively. To use the if simply use \ifyourname <true clause> \else <false clause> \fi where the \else clause is optional.

You code example would be written this way:

\documentclass{article}
\usepackage{tikz}

\newif\ifprintcrop
\printcroptrue
%\printcropfalse

\begin{document}
\begin{tikzpicture}
% other drawing commands
\ifprintcrop
  \draw(0,0) -- ++(0,1);
\fi
% other drawing commands
\end{tikzpicture}
\end{document}

Note that this if-switches are expandable. You shouldn't use \newif inside another \if... clause because this might cause trouble.

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.