3

I am trying to use the optidef package to typeset an optimization problem. I would like to use the cases environment in one of the constraints but LaTeX keeps complaining about an additional } that I cannot seem to find. This is a MWE:

\documentclass{scrartcl}
\usepackage{amsmath}
\usepackage[short,nocomma]{optidef}

\begin{document}
\begin{mini!}
  % Variables
  {x,f}
  %%%%%%%%%%%%%%%%%%%%%%
  % Objective function %
  %%%%%%%%%%%%%%%%%%%%%%
  {%
    \sum_{\{i,j\} \in E} c_{\{i,j\}} x_{\{i,j\}}\label{prob:mst:obj}
  }
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % Problem label and result %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%
  {%
    \label{prob:mst}
  }{%
    % left empty on purpose
  }
  %%%%%%%%%%%%%%%%%%%%%
  % First constraint %
  %%%%%%%%%%%%%%%%%%%%%
  \addConstraint{%
    % LHS
    \sum_{(i,j) \in \delta^+(i)} f_{(i,j)} - \sum_{(j,i) \in \delta^-(i)} f_{(j,i)}
  }{%
    % RHS
    =\,
    \begin{cases}
      \vert V \vert -1 & i=r\\
      -1               & i\neq r
    \end{cases}
    \label{prob:mst:cnstr2}
  }{%
    % Description or quantification
    \quad\forall i \in V
  }
\end{mini!}
\end{document}

enter image description here

This is a snippet taken from the .log file:

./mwe.tex:41: Argument of \reserved@a has an extra }.
<inserted text> 
                \par 
l.41 \end{mini!}
                
I've run across a `}' that doesn't seem to match anything.
For example, `\def\a#1{...}' and `\a}' would produce
this error. If you simply proceed now, the `\par' that
I've just inserted will cause me to report a runaway
argument that might be the root of the problem. But if
your `}' was spurious, just type `2' and it will go away.

Runaway argument?
{\def \@currenvir {cases}\edef \@currenvline {\on@line }\csuse {@begi\ETC.
./mwe.tex:41: Paragraph ended before \reserved@a was complete.
<to be read again> 
                   \par 
l.41 \end{mini!}
                
I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.

./mwe.tex:41: Missing } inserted.
<inserted text> 
                }
l.41 \end{mini!}
                
I've put in what seems to be necessary to fix
the current column of the current alignment.
Try to go on, since this might almost work.

./mwe.tex:41: Extra }, or forgotten $.
<template> }
            $}\ifmeasuring@ \savefieldlength@ \fi \set@field \hfil \endtempl...
l.41 \end{mini!}
                
I've deleted a group-closing symbol because it seems to be
spurious, as in `$x}$'. But perhaps the } is legitimate and
you forgot something else, as in `\hbox{$x}'. In such cases
the way to recover is to insert both the forgotten and the
deleted material, e.g., by typing `I$}'.

./mwe.tex:41: Argument of \reserved@a has an extra }.
<inserted text> 
                \par 
l.41 \end{mini!}
                
I've run across a `}' that doesn't seem to match anything.
For example, `\def\a#1{...}' and `\a}' would produce
this error. If you simply proceed now, the `\par' that
I've just inserted will cause me to report a runaway
argument that might be the root of the problem. But if
your `}' was spurious, just type `2' and it will go away.

Runaway argument?
{\def \@currenvir {cases}\edef \@currenvline {\on@line }\csuse {@begi\ETC.
./mwe.tex:41: Paragraph ended before \reserved@a was complete.
<to be read again> 
                   \par 
l.41 \end{mini!}
                
I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.

./mwe.tex:41: Missing } inserted.
<inserted text> 
                }
l.41 \end{mini!}
                
I've put in what seems to be necessary to fix
the current column of the current alignment.
Try to go on, since this might almost work.

./mwe.tex:41: Extra }, or forgotten $.
<template> }
            $}\ifmeasuring@ \savefieldlength@ \fi \set@field \hfil \endtempl...
l.41 \end{mini!}
                
I've deleted a group-closing symbol because it seems to be
spurious, as in `$x}$'. But perhaps the } is legitimate and
you forgot something else, as in `\hbox{$x}'. In such cases
the way to recover is to insert both the forgotten and the
deleted material, e.g., by typing `I$}'.

As you can see above, the generated PDF looks fine (so why complain then?) but I still wanted to know if others have had the same issue and whether it is safe to ignore the error message for now.

4
  • I get the errors only if I run TeX Live 2016. Isn't it time to upgrade?
    – egreg
    Commented Jun 23, 2021 at 9:26
  • @egreg To be fair, I get the error also with TeXLive2017 ;-) Sadly upgrading is not always an option.
    – campa
    Commented Jun 23, 2021 at 9:30
  • @campa Not with optidef 2017/11/29 - version=2.6 which I have on my TeX Live 2017 distribution. In my TL 2016, the version of optidef is 2.3
    – egreg
    Commented Jun 23, 2021 at 9:32
  • @egreg Oh, I see, I've got 2017/05/24 - version=2.4.
    – campa
    Commented Jun 23, 2021 at 9:34

1 Answer 1

4

I can only reproduce the issue by running TeX Live 2016 (that in its final state has optidef version 2.3).

With TL 2017 and optidef version 2.6 the issue doesn't appear, nor with later versions.

If you cannot upgrade your TeX system from TL 2016 (or 2017) to the current release, there is a workaround: wrap the cases environment in \unexpanded.

\unexpanded{\begin{cases}...\end{cases}}
1
  • Thank you! I asked my system admin for an upgrade (problem solved), so I didn't get to try out the workaround you suggested. I'll keep the \unexpanded trick in memory, though - it may come in handy in the future. Commented Jun 25, 2021 at 7:00

You must log in to answer this question.

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