Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have some long text (a single sentence) which I want to put inside a math environment. But my text just goes accros the page margin and ignores the textwidth specification given in the preamble. Here is a toy example:

\documentclass[12pt]{article}

\setlength{\textwidth}{500pt}
\setlength{\parindent}{0pt}
\setlength{\textheight}{8in}
\usepackage{latexsym,amssymb}
\usepackage{amsmath,array}
\usepackage[margin=1in,headsep=2.5cm]{geometry}

\begin{document}

\begin{math}
2+1=3\\
2+2=4\\ 
{\text{This is some very very very very very very very very very very very 
very very very very very very very very long text in math environment.}} 
\end{math}

\end{document}

Obviously I could just break the line manually but there should be some better way of Latex doing that automatically?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

The math environment is for inline math, I would not use it for multiline math. Also, I would not force multiline text into a math environment. I would leave the math environment, print the text, start a math environment again. A math environment is not the best place for long text.

Your example can be fixed using \parbox, such as

\begin{math}
2+1=3\\
2+2=4\\ 
\parbox{\textwidth}{This is some very ... very long text in math environment.}
\end{math}

This way there would be line breaks with full justification.

But I would either end math mode or use a displayed math environment. You are already using amsmath. In this case I recommend to

  • use an align environment or alike,

  • use \intertext to temporarily escape the math environment for long text,

  • use \text just for short text within math.

share|improve this answer
    
A \strut at the start of the \parbox contents would improve spacing. –  lockstep Jan 15 '12 at 11:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.