General ⇒ Conditional formatting based upon filename (\jobname)
Conditional formatting based upon filename (\jobname)
------------------------
\documentclass{article}
\usepackage{ifthen}
\begin{document}
\huge
\ifthenelse{\equal{test}{\jobname}}{
good
}{
bad: ``\jobname"
}
\end{document}
------------------------
Run it through pdflatex and notice that the output is bad (literally, it says ``bad: ``test""), but the jobname shows test (what the \equal command is comparing against).
What am I missing? I'm working on a project where we'd like to have different content based upon the jobname. Is this type of thing not possible with \jobname?
Thanks!
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Conditional formatting based upon filename (\jobname)
The fact that \jobname results in characters with catcode other. See this old thread for more in-depth explanation and solution to your problem.firebush wrote:What am I missing?
Cheers,
Tomek
Conditional formatting based upon filename (\jobname)
Code: Select all
\documentclass{article}
\usepackage{ifthen}
\begin{document}
\huge
\ifthenelse{\equal{\detokenize{test}}{\jobname}}{
good
}{
bad: ``\jobname"
}
\end{document}
Conditional formatting based upon filename (\jobname)
\detokenize works for our environment. Thanks for the immediate response, all!phi wrote:Code: Select all
\ifthenelse{\equal{\detokenize{test}}{\jobname}}{
Re: Conditional formatting based upon filename (\jobname)
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Conditional formatting based upon filename (\jobname)
These difficulties are no surprise since the underscore is reserved for subscripts in math mode. It seems to cause similar problems as in the path and name of external graphics files.bocchi wrote:Hi it seems that the solution does not work for jobname like test_123.tex
Best regards
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Conditional formatting based upon filename (\jobname)
if anyone has got a solution to suggest it will be very much appreciated as I am working on a project and I cannot change the filenames so I'm pretty much stuck
many thanks
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Conditional formatting based upon filename (\jobname)
So I'm afraid you will have to live with that. Consider to assign proper names to the files in future projects.bocchi wrote:[...] I cannot change the filenames so I'm pretty much stuck [...]
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10