\XDir
. However, the most convenient way that I knew to change it was to use an if/else construct as shown in the following MWE example. The commented line doesn't work (i.e. gives the error that \equal
is unknown) and was therefore replaced with the line immediately preceding it. Code: Select all
\documentclass[12pt,twoside]{report}
\usepackage{xifthen}
\newcommand{\XDir}[1]
{
\ensuremath{\ifthenelse{\equal{#1}{1}}{X}{Y}}
}
\begin{document}
\section[Going in direction $X$]{ Going in direction $\mathbf{X}$ }
%\section[Going in direction \XDir{1}]{ Going in direction $\mathbf{\XDir{1}}$ }
We will go in direction \XDir{1}.
\end{document}
Code: Select all
\documentclass[12pt,twoside]{report}
\usepackage{xifthen}
\newcommand{\XDir}[1]
{
\ensuremath{\ifthenelse{\equal{#1}{1}}{X}{Y}}
}
\newcommand{\myfigurecaption}[3][]
{
\caption{#3}
\label{#2}
\ifthenelse{\isempty{#1}}
{\addcontentsline{lot}{figure}{Figure \ref{#2}: #3}}
{\addcontentsline{lot}{figure}{Figure \ref{#2}: #1}}
}
\begin{document}
We will go in direction \XDir{2}.
\begin{figure}
\myfigurecaption[Let's look at direction $Y$]{fig:myfigure}{Let's look at direction $\mathbf{Y}$}
% \myfigurecaption[Let's look at direction $\XDir{2}$]{fig:myfigure}{Let's look at direction $\mathbf{\XDir{2}}$}
\end{figure}
\end{document}
\XDir
sometimes works and sometimes does not. Perhaps my misunderstanding stems from the fact that I am a C++ trained (functional and OOP) individual who doesn't understand the inner workings of macro expansion.I could manually go through and make changes like above (with the commented lines), but I would like to learn a more elegant, proper solution.
Thanks