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 am not sure which one is correct when using \intertext or \shortintertext. Adding \\ before them or not.

\documentclass[preview,border=12pt]{standalone}
\usepackage{amsmath}
\begin{document}
\section*{Without a line break }
\begin{gather*}
E = mc^2
\intertext{Multiply both side by 2, we have}
2E = 2mc^2
\end{gather*}

\section*{With a line break}
\begin{gather*}
E = mc^2\\
\intertext{Multiply both side by 2, we have}
2E = 2mc^2
\end{gather*}
\end{document}

enter image description here

I don't see any differences. Or there is something wrong with my eyes. So the question is: Is it necessary to give a \\ before \intertext or \shortintertext?

share|improve this question
    
According to amsmath documentation: "\intertext may only appear right after a \\ or \\* command", but it seems to work without as well... –  karlkoeller Nov 10 '13 at 6:44
    
@karlkoeller: That is why I am always confused with it when writing... –  cyanide-based food Nov 10 '13 at 6:48

1 Answer 1

up vote 7 down vote accepted

For \intertext to work, it has to be in vertical mode, which means it should follow \\. However, \intertext does a check to see whether this is the case (...\ifvmode\else\\\@empty\fi...). If not, it attempts to insert it. As such, the use of it may be considered cautiously optional.

From the amsmath documentation (p 33 onward):

The \intertext command is used for inserting text between the rows of an alignment. It might better be done as an environment, but the \begingroup from \begin would cause the \noalign to fail.

\newcommand{\intertext}{\@amsmath@err{\Invalid@@\intertext}\@eha}

\intertext@ is called by all environments that allow the use of the \intertext command.

\def\intertext@{%
  \def\intertext##1{%

If current mode is not vmode, the most likely reason is that the writer forgot the \\ that is supposed to precede \intertext. All right, then, let's try adding it our ownself. But, to be slightly careful: \\ does a futurelet, and it's slightly dangerous to allow a letted token to barge around loose in our internal code when it has been let to a conditional token like \fi. So let's interpose something in front of the \fi for the futurelet to take instead. (And careful again: it has to be something evanescent, not (e.g.) \relax which would cause the next halign cell to fire up and keep \noalign from working.)

    \ifvmode\else\\\@empty\fi
    \noalign{%
      \penalty\postdisplaypenalty\vskip\belowdisplayskip
      \vbox{\normalbaselines

We need to do something extra if the outside environment is a list environment. I don't see offhand an elegant way to test "are we inside any list environment" that is both easy and reliable (for example, checking for zero \@totalleftmargin wouldn't catch the case where \@totalleftmargin is zero but \linewidth is less than \columnwidth), so it seems to me checking \linewidth is the best practical solution.

         \ifdim\linewidth=\columnwidth
         \else \parshape\@ne \@totalleftmargin \linewidth
         \fi
         \noindent##1\par}%
       \penalty\predisplaypenalty\vskip\abovedisplayskip%
     }%
}}
share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.