I have a macros.tex
included in the preamble that creates some useful dumb macros. I want to define a macro for writing fractions that adds a brace if the argument is longer than 1 character, what I have so far is:
\usepackage{xstrings}
\newcommand{\fracdivide}[3]{%
\StrLen{#2}[\arglen]%
\ifthenelse{\arglen > 1}
{%
\frac{#1\left(#2\right)}{#1#3}
}%
{%
\frac{#1#2}{#1#3}
}%
}
That produces the following error:
!Incomplete \iffalse; all text was ignored after line 16
.
line 16
is exactly the line where I have the \StrLen
command. If I remove it (for example using 2
instead of \arglen
), it compiles correctly.
Why do I get this error? And how do I solve it?
Here's a MWE, it seems related to the \text
command of amsmath
.
\documentclass{minimal}
\usepackage{mathtools}
\usepackage{xstring}
\usepackage{ifthen}
\newcommand{\vect}[1]{\boldsymbol{\mathbf{#1}}}
\newcommand{\fracdivide}[3]{%
\StrLen{#2}[\arglen]%
\ifthenelse{\arglen > 1}
{%
\frac{#1\left(#2\right)}{#1#3}
}%
{%
\frac{#1#2}{#1#3}
}%
}
\newcommand{\partialdd}[2]{\fracdivide{\partial}{#1}{#2}}
\newcommand{\ddt}[1]{\partialdd{#1}{t}}
\begin{document}
$\ddt{f^\text{big}}$
\end{document}
\fracdivide
. Possibly some other command fromxstrings
, but I've never used that package before.