3

The following code produces error ! Missing \endgroup <inserted text>. What is causing the error? It seems that the breqn is not working inside tabular environment.

\documentclass{article}
\usepackage{breqn}
\begin{document}
\begin{tabular}{l}
\begin{dmath*}
  f (1.02) + f (1.06) + f (1.1)  + f (1.14) + f (1.18) + f (1.22) + 
  f (1.26) + f (1.3)  + f (1.34) + f (1.38) + f (1.42) + f (1)
\end{dmath*}
\end{tabular}
\end{document}
6
  • Just out of idle curiosity: What's your use case for embedding a dmath* environment inside a single-column tabular environment?
    – Mico
    Commented Jul 24, 2023 at 9:34
  • 1
    For referencing purpose. The output is put in a table which is referred.
    – user61681
    Commented Jul 24, 2023 at 9:42
  • @user61681 You don't need a tabular inside a table environment. You can have anything; of course you need a caption if it should be referenced.
    – egreg
    Commented Jul 24, 2023 at 9:45
  • Thank you for making it clear. I need referencing with caption.
    – user61681
    Commented Jul 24, 2023 at 9:50
  • So you need a table (or maybe figure?) environment in order for \caption (and \label) to make sense. You do not need to encase the dmath* environment in a tabular environment inside said table environment.
    – Mico
    Commented Jul 24, 2023 at 10:00

3 Answers 3

3

dmath is a vertical display construct so can not work in an l column which is like \mbox. Use a p{...} column so it is in vertical mode, and has a target width for line breaking.

4
  • @user61681 as egreg commented later, a one row one column tabular isn't needed at all, I assumed that was just an artifact of making a minimal example so did not comment on that here. Commented Jul 24, 2023 at 10:07
  • Yes. It was minimal example. I indeed need three columns in some cases. For one row, one column tabular is not required.
    – user61681
    Commented Jul 24, 2023 at 10:14
  • @user61681 anyway you will have made egreg very happy, he's always delighted when we both answer a question, and I get the green tick. Commented Jul 24, 2023 at 10:16
  • It is always helpful and pleasure to get responses from highly expertise people like you.
    – user61681
    Commented Jul 24, 2023 at 10:18
3

I see no reason for a tabular.

\documentclass{article}
\usepackage{breqn}

\begin{document}

You can see an important quantity in table~\ref{q-important}.

\begin{table}[htp]

\begin{dmath*}
  f (1.02) + f (1.06) + f (1.1)  + f (1.14) + f (1.18) + f (1.22) + 
  f (1.26) + f (1.3)  + f (1.34) + f (1.38) + f (1.42) + f (1)
\end{dmath*}

\caption{This is an important quantity\label{q-important}}

\end{table}

\end{document}

enter image description here

0

For referencing purpose. The output is put in a table which is referred

You could remove the star and have a numbered equation to refer to. If you have a particular use case for captions, you may consider creating and formatting a custom float with a new label. It is also possible to format references.

Here is example code with an arbitrary new float annotation

\documentclass{article}
\usepackage{breqn}
\usepackage{newfloat,caption,cleveref}

\DeclareFloatingEnvironment[
  fileext=note,
  listname={List of annotations},
  name=Annotation,
  placement=htp,
]{annotation}
\captionsetup[annotation]{position=bottom,skip=3pt}   % labelfont=bf
\crefformat{annotation}{Annotation~(#2#1#3)}

\usepackage{kantlipsum}   % for dummy texts


\begin{document}
% \listofannotations\vspace{\baselineskip}   % Creates a list of annotations

\kant[1][1]

\begin{annotation}
  \begin{dmath*}
    f (1.02) + f (1.06) + f (1.1)  + f (1.14) + f (1.18) + f (1.22) + 
    f (1.26) + f (1.3)  + f (1.34) + f (1.38) + f (1.42) + f (1)
  \end{dmath*}
  \caption{Sum of functions}\label{note:1}
\end{annotation}

\kant[1][2]

A regular reference: \eqref{note:1}, and reference with a label via \verb!cleveref!: \Cref{note:1}.
\end{document}

enter image description here

You must log in to answer this question.

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