1

What construct should I use to lay something out so that it has a \label (as it will be the target of future cross-references), and where the text within it wraps?

Environments align and gather enable the cross-referencing using \label and \ref but not the line-wrapping. (Text should wrap automatically, so that, when I edit the text in future, that doesn't entail me finding out which words should begin the respective lines.)

I thought the following would do, but no label appears in the output PDF, and the \ref reference is typeset as the section number (if the text is in a section).

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\begin{document}
The first few values are as follows:

\begin{table}[h]
\begin{tabular}{p{15cm}}
$m = 2$, 3, 5, 11, 29, 47, 59, 71, 83, 101, 131, 137, 149, 167, 173, 197, 233, 251, 257, 269, 281, 293, 311, 317, 347, 443, 461, 467, 479, 491, 503, 569,\dots.
\end{tabular}\label{m}
\end{table}

Lorem ipsum etc.

Later text referring back to sequence \ref{m}.
\end{document}

I tried the same but with $\begin{array} and \end{array}$ instead of tabular, but that didn't produce a label either.

Although I have used the environment table to try to get what I want, the thing is semantically some text such as would be laid out using a gather environment (just with line-wrapping). So I'd like it to look like a numbered equation. So giving the table a \caption would not produce what I would like.

Furthermore, as befits ia numbered equation, the layout engine should allocate the same number for the label as it would if the \label had occurred in a gather or align environment. What environment, though, allows this and also allows automatic text line wrapping?

6
  • 1
    what output to you want from \ref{m}? What should it reference? Commented Apr 25, 2021 at 14:18
  • @UlrikeFischer A number -- exactly which number is out of my control. I would like the same format of cross-references as you would get from \begin{align} a &= b \label{ab}\end{align}. So that if the layout engine typesets (5) for the label, then it should typeset 5 for a later \ref{ab}..
    – Rosie F
    Commented Apr 25, 2021 at 14:33
  • 1
    sorry but if you simply want an arbitrary number, then type 42 instead of \ref{m}. If you want a specific number, you should say which one of all numbers in your example you want, and why this specific one and not the next. Commented Apr 25, 2021 at 14:44
  • @UlrikeFischer I think I see your point... I would like the number to be the same as the equation number which the layout engine would allocate if the \label were in an align or gather environment. So the question is which environments are there, which are like align or gather in that a \label in it turns into a number in the same equation-numbering sequence, and which enables automatic line-wrapping. I'll update the question.
    – Rosie F
    Commented Apr 25, 2021 at 14:53
  • I'm afraid your write-up is very confusing. For instance, why do you show table and tabular environments if what you really want to cross-reference is a multi-line equation? Or am I missing something rather fundamental? Please clarify.
    – Mico
    Commented Apr 25, 2021 at 14:55

1 Answer 1

3

You can only label a caption, if you're in a table environment.

But I guess you want something like

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}

\begin{document}

The first few values are as follows:
\begin{equation}\label{m}
\parbox[b]{0.8\displaywidth}{\raggedright
  $m ={}$2, 3, 5, 11, 29, 47, 59, 71, 83, 101, 131, 137, 149, 167, 173,
  197, 233, 251, 257, 269, 281, 293, 311, 317, 347, 443, 461, 467, 479,
  491, 503, 569, \dots.
}
\end{equation}
Lorem ipsum etc.

Later text referring back to sequence \ref{m}.

\end{document}

enter image description here

1
  • 1
    Good advice about \parbox (which I hadn't used before, and will now bear in mind) and \displaywidth.
    – Rosie F
    Commented Apr 25, 2021 at 17:39

You must log in to answer this question.

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