Math & ScienceMulti-line Sentence with Equation Number

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
itmethenerd
Posts: 3
Joined: Mon Apr 09, 2012 12:57 pm

Multi-line Sentence with Equation Number

Post by itmethenerd »

Hi all. A beginner here, so possibly an easy question.

I wish to give a sentence an equation number. I've looked online an apparently I can use \text of \mbox like this:

Code: Select all

\begin{equation}\label{result}
\text{Given a game B which is normally losing, it is possible to determine a winning strategy, if and only if the player obeys the following long list of instructions.}
\end{equation}
The problem is the sentence is wider than my page so it extends off the page. How can I get line breaks in? (I don't care if it uses \text or something else, but I do want an equation number).

Thanks in advance.
Last edited by localghost on Mon Apr 09, 2012 1:32 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Multi-line Sentence with Equation Number

Post by localghost »

Wherever you need line breaks, a \parbox will be helpful.

Code: Select all

\begin{equation}\label{result}
  \parbox{0.8\linewidth}{
    Given a game B which is normally losing, it is possible to determine a winning strategy, if and only if the player obeys the following long list of instructions.
  }
\end{equation}
Perhaps it's better to write such sentences in a theorem-like environment for appropriate formatting (and numbering).

Code: Select all

\documentclass[11pt]{report}
\usepackage{fixltx2e}
\usepackage[T1]{fontenc}

\newtheorem{result}{Result}[chapter]

\begin{document}
  \chapter{Foo}
    \begin{result}[Winning strategy]\label{res:winning-strategy}
      Given a game B which is normally losing, it is possible to determine a winning strategy, if and only if the player obeys the following long list of instructions.
    \end{result}
\end{document}
Such theorem environments are enhanced by amsthm and ntheorem, whereby only one package makes sense.


Best regards and welcome to the board
Thorsten
itmethenerd
Posts: 3
Joined: Mon Apr 09, 2012 12:57 pm

Multi-line Sentence with Equation Number

Post by itmethenerd »

Thanks. I couldn't get parbox to do what I wanted (the text still went off the page), but the parbox documentation pointed me to minibox, which did the right thing. I also had to remove the "text" command, and add the "it" command to give it italics:

Code: Select all

\begin{equation}\label{result}
\begin{minipage}{130mm}
{it Given a game B which is normally losing, it is possible to determine a winning strategy, if and only if the player obeys the following long list of instructions.}
\end{minipage}
\end{equation}
This gives text offset from other text in the document, with an equation number to the right.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Multi-line Sentence with Equation Number

Post by localghost »

itmethenerd wrote:[…] I couldn't get parbox to do what I wanted (the text still went off the page), but the parbox documentation pointed me to minibox, which did the right thing.[…]
Could you elaborate the difficulties with the \parbox command by a minimal example? For me it works just fine.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Multi-line Sentence with Equation Number

Post by Stefan Kottwitz »

itmethenerd wrote:I couldn't get parbox to do what I wanted (the text still went off the page)
\parbox takes a width as argument. Perhaps you did not use that or it was simply too big. Otherwise it should work like minipage did here. As Thorsten said, perhaps show what you tried, so we could help you to understand what's wrong. Often \parbox is sufficient and you don't need to use minipage.

Furthermore, an absolute width of 130mm might be ok at first sight, but let's say you used such absolute width minipages or boxes a lot, and then change your document text width - you would possibly have to adjust at many places. A relative width such as 0.8\linewidth would make life easier.

Btw. the \it command is old and obsolete, better use \itshape instead. I even would use \em or \emph instead. (see Font styles).

Stefan
LaTeX.org admin
itmethenerd
Posts: 3
Joined: Mon Apr 09, 2012 12:57 pm

Re: Multi-line Sentence with Equation Number

Post by itmethenerd »

Obviously I made a mistake the other night, because parbox now works just as well as minipage. I'll also take on board the other comments width and italics too. Thanks to both of your for your help.
Post Reply