LaTeX forum ⇒ GeneralRecovery 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

Postby leo simon » Mon Apr 29, 2013 7:08 pm

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.
  1. \documentclass{amsart}
  2. \usepackage{currfile}
  3. \usepackage{currfile-abspath}
  4. \usepackage{ifthen}
  5.  
  6. \begin{document}
  7. \getpwd
  8.  
  9. The current file name is \currfilepath
  10.  
  11. Pwd is set to \thepwd
  12.  
  13. \ifcurrfilepath{testCurrfile.tex}
  14. {The current filename is \currfilepath}
  15. {Apparently the current filename is not \currfilepath}
  16.  
  17. \ifthenelse{\equal{\currfilepath}{testCurrfile.tex}}
  18. {The current filename is \currfilepath}
  19. {Apparently the current filename is not \currfilepath}
  20.  
  21. \ifthenelse{\equal{\thepwd}{/tmp}}
  22. {The current directory is \thepwd}
  23. {Apparently the current directory is not \thepwd}
  24.  
  25.  
  26. \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

Tags:

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

Postby tom » Wed May 01, 2013 12:05 pm

Hi!

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

  1. %Preamble
  2. \usepackage[abspath]{currfile}
  3. \usepackage{ifthen, pdftexcmds}
  4.  
  5. \newif\ifequal
  6. \makeatletter
  7. \def\isequal#1#2{
  8. \ifnum\pdf@strcmp{#1}{#2}=0
  9. \equaltrue
  10. \else
  11. \equalfalse
  12. \fi
  13. }
  14. \makeatother
  15.  
  16. %Document
  17. \isequal{\currfilepath}{testCurrfile.tex}
  18. \ifequal
  19. The current filename is \currfilepath
  20. \else
  21. Apparently the current filename is not \currfilepath
  22. \fi


HTH,
Tom

leo simon
Posts: 17
Joined: Wed Aug 19, 2009 5:41 pm

Postby leo simon » Thu May 02, 2013 12:03 am

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


Return to “General”

Who is online

Users browsing this forum: No registered users and 3 guests