1

In LaTeX formulas can be automatically numbered like this:

\begin{equation}
  1+1=2
\end{equation}

\begin{equation}
  1+2=3
\end{equation}

This will produce something like that:

1+1=2                                   (1)
1+2=3                                   (2)

(Although the formulas will be centered.)

It is also possible to add a manual tag to replace the number and add a label to refer to the formula later:

\begin{equation} \tag{myTag} \label{myLabel}
  2+2=4 
\end{equation}

Which will look like this:

2+2=4                               (myTag)

However, this is only possible with math formulas. Is there also a way to make this type of formatting/numbering also work with ordinary text, i.e. short statements?

For example, it should look like this:

This is my statement.                   (3)
4
  • 4
    Is \begin{equation} \mbox{This is my statement.} \end{equation} acceptable?
    – Mico
    Jan 9, 2021 at 21:10
  • @Mico Great! Although this doesn't work if the statement is more than one line long... Then it goes over the margin. Is there perhaps some way to support atomatic/manual line breaks?
    – Max
    Jan 9, 2021 at 21:27
  • @Mico I found a possibility to add manual line breaks: \begin{align} &\mbox{My very long statement is continued}\\ &\mbox{in the second line.} \notag \end{align} This should work. :) If you want to add an answer I'll accept it.
    – Max
    Jan 9, 2021 at 21:41
  • 1
    If you need a different numbering scheme than equations, you might see the numberedblock package: tex.stackexchange.com/questions/202966/how-can-i-show-codeboxes/… and tex.stackexchange.com/questions/170435/… Jan 9, 2021 at 23:41

1 Answer 1

1

If the text-mode statement is short, i.e., if it fits comfortably within a single line, I'd suggest encasing the statement in an \mbox directive:

\begin{equation} 
  \mbox{This is my statement.} 
\end{equation}

In contrast, if there's a chance that your text-mode statement will span two or more lines, I'd suggest using a \parbox directive to house the text:

enter image description here

\documentclass{article}
\usepackage{amsmath}
\usepackage{lipsum}    % filler text
\usepackage{showframe} % show frame lines around text block
% create a bespoke macro:
\newcommand\textbox[1]{\parbox{0.75\textwidth}{\raggedright #1}}

\begin{document}
\begin{equation}
  \textbox{\lipsum[1][1-4]}
\end{equation}
\end{document}
1
  • Thank you, this works! :)
    – Max
    Jan 9, 2021 at 21:55

You must log in to answer this question.

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