4

I'm pretty new to latex and having some trouble. I have multiple math formulas which I'd like to organize on the page. i used:

\begin{tabular}{p{6cm}p{6cm}}
\[...\] & \[...\]\\
\end{tabular}

for this. The problem is the following one: the first formula has different indent depending on its own length (the second one is always on the same place).I guess it's the centering of the displaymath? Is there a way to have the display mode and always the same indent, or should I use another environment?

  • 2
    Welcome to TeX.SE. You can use $\displaystyle ...$. Also, while code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. – Peter Grill Jun 13 '14 at 21:02
  • @PeterGrill Can you make than answer. – Andrew Swann Dec 29 '14 at 9:15
3

The problem is with the use of display math mode. Instead you could use inline math and specify \displaystyle:

enter image description here

If your tables only have math content then I would suggest using an array as in the last example above. Although, I am not sure why the spacing is slightly different.

Notes:

  • I am not advocating the user of vertical rules. They were added just to show where the content is with respect to the borders.

Code:

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}

\begin{document}
\noindent
Using \verb|display math mode|

\noindent
\begin{tabular}{|p{6cm}|p{6cm}|}
\[ y =\sum_{i=0}^{n} i^2 \] & \[ y =\sum_{i=0}^{n} i^2  \] \\
\end{tabular}

\medskip\noindent
Using \verb|\displaystyle|

\noindent
\begin{tabular}{|p{6cm}|p{6cm}|}
$\displaystyle y =\sum_{i=0}^{n} i^2$ & $\displaystyle y =\sum_{i=0}^{n} i^2$ \\
\end{tabular}

\medskip\noindent
Using \verb|\displaystyle| with an \verb|array|:

\noindent
$\begin{array}{|>{$\displaystyle}p{6cm\relax}<{$}|>{$\displaystyle}p{6cm}<{$}|}
 y =\sum_{i=0}^{n} i^2 & \displaystyle y =\sum_{i=0}^{n} i^2 \\
\end{array}$


\end{document}
1

This is meant as an addition to Peter's answer.

For a fixed-indentation in your tabular, insert an \hspace*{<len>} or \quad/\qquad:

enter image description here

\documentclass{article}
\usepackage{array}
\newcolumntype{M}[1]{>{$\displaystyle\qquad}p{#1}<{$}}

\begin{document}

\noindent
\begin{tabular}{|M{6cm}|M{6cm}|}
 y =\sum_{i=0}^{n} i^2 & \displaystyle y =\sum_{i=0}^{n} i^2 \\
 y =\sum_{i=0}^{n} (i+1)^2 & \displaystyle y =\sum_{i=0}^{n} i^2 \\
 y =\sum_{i=0}^{n} \bigl(i^2+i+1\bigr)^2 & \displaystyle y =\sum_{i=0}^{n} i^2 \\
\end{tabular}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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