1

I would like to put a \xRightarrow into a list instead of a bullet, unfortunately I get

! Argument of \\xRightarrow has an extra }.
<inserted text> 
                \par 
l.8     \item[$\xRightarrow[continuous]
                                    {norm}$] Test

This is from the MWE:

\documentclass{article}

\usepackage{amsmath}
\usepackage{mathtools}

\begin{document}
\begin{itemize}
    \item[$\xRightarrow[continuous]{norm}$] Test
\end{itemize}
\end{document}

using

$ pdflatex --version
pdfTeX 3.14159265-2.6-1.40.20 (TeX Live 2019/Arch Linux)
$ lualatex --version
This is LuaTeX, Version 1.10.0 (TeX Live 2019/Arch Linux)

How can I fix this?

Edit: as @Phelype Oleinik points out in the comments, this is related to parsing the braces [,].

camelCase
  • 105
  • 3
    Try \item[{$\xRightarrow[continuous]{norm}$}], i.e. add braces around $\xRightarrow[continuous]{norm}$. –  Dec 04 '19 at 23:11
  • @Schrödinger'scat Ok thanks, nice and easy solution. – camelCase Dec 04 '19 at 23:16
  • 1
    @PhelypeOleinik Thanks for your reply, but I dont see how this is linked to my problem. – camelCase Dec 04 '19 at 23:23
  • 1
    @camelCase The problem is the same (TeX's delimited argument parser), even though the application (optional argument vs. key-value parsing) is a bit different. The delimited macro \item looks for a [ and the first brace-balanced ], which (without the braces in Mr. Cat's suggestion) ends up being $\xRightarrow[continuous, and then chaos ensues. The braces prevent that. This is explained in my answer to the linked question (see the 5th paragraph there). If after reading that you still disagree on the duplicate, I'll remove my comment, no problem :-) – Phelype Oleinik Dec 04 '19 at 23:28
  • @PhelypeOleinik So this actually is a duplicate. Thanks for clarification. – camelCase Dec 04 '19 at 23:34
  • @camelCase You're welcome! Glad it helped :-) Actually, you will find many things related to this, but the two most common (in LaTeX, at least) are optional arguments and comma-separated lists. But that's basically because TeX, Under Usual Circumstances™ doesn't balance [...] as it balances {...}. There are exceptions, for example commands defined with xparse. If you did \NewDocumentCommand\test{O{z}}{(#1)} and used \test[a[b]c] you'd get (a[b]c), whereas if you used the equivalent \newcommand\test[1][z]{(#1)} you'd get (a[b)c] for the same input. – Phelype Oleinik Dec 04 '19 at 23:46

0 Answers0