[Tex/LaTex] question of \ifstrequal in etoolbox

etoolbox

I collaborate with multiple people to write latex documents, over dropbox, and the paths to the various folders (where the graphs and bibliographics reside, for instance) are distinct for each of the collaborators. So I am trying to use etoolbox to define a variable "whoami", so that the person currently editingthe file can change it once in the beginning and everything will get changed in the document. However, it's not behaving as expected; here's a minimal non-working example:

\documentclass{article}
\usepackage{etoolbox}

\newcommand{\whoami}{PB}

\begin{document}

\ifstrequal{\whoami}{PB}{%
I am PB}{% false
I am not PB}

\end{document}

I was expecting the output to yield "I am PB", but it yields "I am not PB". I suspect \whoami is not of the string data type, if such a thing exists (sorry, don't know much TeX, only LaTeX). I also tried to define "whoami" using \string:

\def\whoami{\string PB}

That didn't work as well, and in fact made things worse! Any help will be appreciated.

Best Answer

If you are really have to handle "multiple" people, I wouldn't use \if-whatever to choose. This can get quite confusing and error prone if you have to add more definitions or more people. I would use something like this:

\documentclass{article}
\usepackage{etoolbox}

\csdef{path-PB}{path of PB}
\csdef{path-UF}{path of UF}
% more definitions

\newcommand\whoami{PB}

\newcommand\mypath{\csuse{path-\whoami}}
\begin{document}

\mypath

\renewcommand\whoami{UF}

\mypath


\end{document}
Related Question