6

is there a way to insert a centered line of text or mathematics inside an align-environment?

For example, in the code below, I'd like to have the \vdots between the equations above and below horizontally centered, completely ignoring the alignment markers:

\documentclass{article}
\begin{document}
\begin{align}
  f(1) &= 1 \\
  f(2) &= 2 \\
  \vdots & \\
  f(n) &= n f(n-1)
\end{align}
\end{document}
1
  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.
    – jub0bs
    Aug 15, 2014 at 7:01

2 Answers 2

4

Like this?

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\noindent X\hrulefill X
  \begin{align}
  f(1) &= 1 \\
  f(2) &= 2 \\
  \shortintertext{\hfil    \vdots \hfil}
  f(n) &= n f(n-1) xxxxxxx
\end{align}
\end{document}

enter image description here

6
  • Sorry, apparently I wasn't clear enough when asking the question (I have edited it and added more details). What I want are vdots which are centered independently from all the alignment markers and the content which is above and below. With vdotswithin you have to choose a center point which depends on the alignment markers. Aug 15, 2014 at 6:47
  • @r_faszanatas centered with respect to what? the text width?
    – user11232
    Aug 15, 2014 at 6:52
  • @r_faszanatas Is it like the updated one? If not, I will delete this :-)
    – user11232
    Aug 15, 2014 at 7:05
  • That's what I was looking for, thank you very much! Aug 15, 2014 at 7:15
  • 1
    @LucasSoares It is defined by mathtools. This leaves little tight vertical space compared to \intertext (which is defined by amsmath).
    – user11232
    May 11, 2015 at 16:36
2

The “official” way of doing this is

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{align}
  f(1) &= 1 \\
  f(2) &= 2 \\
       &\vdotswithin{=} \nonumber \\
  f(n) &= n f(n-1) xxxxxxx
\end{align}
\end{document}

enter image description here

But this doesn't answer the question, though. So… why would you like \vdots that ignore the content of align in a “text” line?

1
  • I'm well aware of the "official" way but in my case it was visually unappealing. I have a long chain of aligned equations $f(k)= ...$, just like in your example above, where the right hand side is very long and takes up about 90% of the column width. Vdots under the equal sign just don't look good to me in this case. An example for a centered text line would be something like \intertext{- using our convention that ... -}, which looks better centered than left justified. Again, "better" is of course highly subjective. Aug 15, 2014 at 7:51

You must log in to answer this question.

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