LaTeX forum ⇒ General ⇒ Recovery of Value by Condition Topic is solved

LaTeX specific issues not fitting into one of the other forums of this category.
leo simon
Posts: 17
Joined: Wed Aug 19, 2009 5:41 pm

Recovery of Value by Condition

Hi,

I'm trying to condition on the current directory using the "currfile-abspath" package from currfile by means of ifthen. The command \getpwd does recover the pwd, but for some reason I can't condition on the value of \thepwd using ifthen. The problem seems to be with the ifthen command, since I *can* condition on the value of \currfilepath so long as I use the provided \ifcurrfilepath, but *not* if I use an ifthen statement.

Here's an example.
\documentclass{amsart}\usepackage{currfile}\usepackage{currfile-abspath}\usepackage{ifthen} \begin{document}\getpwd The current file name is \currfilepath Pwd is set to \thepwd \ifcurrfilepath{testCurrfile.tex}     {The current filename is \currfilepath}     {Apparently the current filename is not \currfilepath} \ifthenelse{\equal{\currfilepath}{testCurrfile.tex}}     {The current filename is \currfilepath}     {Apparently the current filename is not \currfilepath} \ifthenelse{\equal{\thepwd}{/tmp}}     {The current directory is \thepwd}     {Apparently the current directory is not \thepwd}  \end{document}

If I run this from, say, /tmp, (I'm using Linux) then \thepwd correctly returns /tmp/ but the ifthen conditional fails. Also the \ifcurrfilepath returns true, but the \equal{\currfilepath}{testCurrfile.tex} returns false.

Any advice would be most appreciated, Thanks

tom
Posts: 73
Joined: Thu Apr 18, 2013 4:02 am
Hi!

It seems \equal only works with numbers. Use \pdf@strcmp instead (pdftexcmds).

%Preamble\usepackage[abspath]{currfile}\usepackage{ifthen, pdftexcmds} \newif\ifequal\makeatletter\def\isequal#1#2{	\ifnum\pdf@strcmp{#1}{#2}=0		\equaltrue	\else		\equalfalse	\fi}\makeatother %Document\isequal{\currfilepath}{testCurrfile.tex}\ifequal	The current filename is \currfilepath\else	Apparently the current filename is not \currfilepath\fi

HTH,
Tom

leo simon
Posts: 17
Joined: Wed Aug 19, 2009 5:41 pm
Thank you very much indeed, Tom, this is perfect, Leo