1

When I delete the second \item, it compiles fine. However, with the second \item, I get ERROR: Missing $ inserted and the math renders incorrectly:

\documentclass[12pt]{article}

\newcommand \frob[2] {\langle #1,#2 \rangle_F}

\begin{document}
\begin{itemize}

\item What I want: $ 
\langle A,B \rangle_F 
\geq 
\langle C,D \rangle_F
$. 

\item What I get: $ 
\frob{A,B} 
\geq 
\frob{A,B} 
$.

\end{itemize}
\end{document}

the issue

Would appreciate any help with this issue!

1
  • Don't use \frob as \frob{A,B} but use it as \frob{A}{B}. Your \frob-macro does process two arguments which are not comma-separated. As result it delivers something where the phrases delivered via the arguments will be comma-separated. Maybe this confused you. ;-) If you do \frob{A,B}\geq, \frob's first undelimited argument will be formed from {A,B} and \frob's second undelimited argument will be formed from \geq. So all in all \frob{A,B} \geq \frob{A,B} should be \frob{A}{B}\geq\frob{C}{D} . Commented Feb 2, 2019 at 1:45

1 Answer 1

2

You defined \frob to take two arguments

\newcommand{\frob}[2]

However, you're only passing it one argument when you use it like this

\frob{A,B}

That's because arguments are specified as tokens or using braces {...}, not a comma-separated list of elements.

Since you're printing the same thing as you're passing, the following might be simpler:

enter image description here

\documentclass{article}

\newcommand{\frob}[1]{\langle #1 \rangle_F}

\begin{document}

\begin{itemize}
  \item
    What I want: $ 
    \langle A,B \rangle_F 
    \geq 
    \langle C,D \rangle_F
    $. 

  \item 
    What I get: $ 
    \frob{A,B} 
    \geq 
    \frob{A,B} 
    $.
\end{itemize}

\end{document}

If you really want to pass two arguments, then your definition should be

\newcommand{\frob}[2]{\langle #1, #2 \rangle_F}

and you'll use it via \frob{A}{B}.

1
  • Ah, obviously! I've used \frac that way, but somehow had a brain fart when defining my own function. Thanks! Commented Feb 2, 2019 at 22:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .