GeneralRecovery of Value by Condition

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

Recovery of Value by Condition

Post by leo simon »

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.

Code: Select all

Code, edit and compile here:
\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}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

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

Recovery of Value by Condition

Post by tom »

Hi!

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

Code: Select all

Code, edit and compile here:
%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
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
HTH,
Tom
leo simon
Posts: 17
Joined: Wed Aug 19, 2009 5:41 pm

Re: Recovery of Value by Condition

Post by leo simon »

Thank you very much indeed, Tom, this is perfect, Leo
Post Reply