# ifthenelse no else with string comparison [closed]

Answer below

### Issue

I am using the package xifthen to try and check if a string variable is equal to a specific string in order to input something. I only want to do something in case the test is validated, meaning no else.

i.e. \ifthenelse{<test>}{true}{}

When testing the string against an integer (e.g. \equal{string}{1}), it works as expected. However, when checking against a string (e.g. \equal{string}{test}) it breaks if no value is set for the else part.

 Here is the error message I get: The document does compile if I build it at least twice, but fails the first time.

### Question

Why is that so? How can I fix it or find a workaround?

### MWE

\documentclass{article}
\usepackage{mwe}
\usepackage{xifthen}
\begin{document}
\ifthenelse{\equal{string}{1}}{1}{}
\smallbreak
\ifthenelse{\equal{string}{test}}{true}{}
\end{document}


# Edit & answer

The MWE does not output anything which makes latexmk crash. By outputing one thing before or after, it works as expected.

## closed as off-topic by egreg, user36296, Zarko, Martin Schröder, Torbjørn T.Mar 14 '17 at 14:04

• This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

• Not tested but try \ifthenelse{\equal{string}{test}}{true}{\relax}. What does \relax do? – Chris H Mar 13 '17 at 14:44
• @ChrisH Sadly, it does not fix the issue. – Florian Mar 13 '17 at 14:50
• Your MWE works as expected. However, you probably don't intend for string and test to be literals, but rather some macro or something?? Please clarify. – Steven B. Segletes Mar 13 '17 at 14:59
• There is no error shown in the log that you posted. But there is no pdf output either (as it doesn't make any output) perhaps latexmk was not expecting that. – David Carlisle Mar 13 '17 at 16:50
• I'm voting to close this question as off-topic because the issue is due to latexmk not recognizing that no pdf file has been produced – egreg Mar 14 '17 at 12:56