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.

Regarding this post:

Table with text wrapping?

\documentclass{article}
\usepackage{array}
\newcolumntype{L}{>{\centering\arraybackslash}m{3cm}}

\begin{document}

\begin{table}
\begin{tabular}{|L|c|L|}\hline
one & two & three \\\hline
This is two line thing and centered & only one line&  \multicolumn{1}{m{3cm}|}{This is justified and may go to second line as well, neatly}\\\hline
  one & two & three \\\hline
  one & two & three \\\hline
\end{tabular}
\end{table}
\end{document}

Now I would like to enhance this table as follows:

  1. Turn the Row 2, Column1 text into two equations aligned at the "=" within that cell. That is:

    y=mx+b
    y=x+1

  2. Insert caption and label

  3. Position the table and caption in the center of the page
share|improve this question
add comment

1 Answer

Check out the following modified form of your MWE.

\documentclass{article}
\usepackage{array,amsmath}
\newcolumntype{L}{>{\centering\arraybackslash}m{3cm}}
\begin{document}
\begin{table}
\caption{The table's caption goes here}\label{tab:example}
\centering
\begin{tabular}{|L|c|L|}\hline
one & two & three \\
\hline
This is two line thing and centered & only one line&  
\multicolumn{1}{m{3cm}|}{This is justified and may go to second line as well, neatly}\\
\hline
  $\begin{aligned}
  y&=mx+b\\
  y&=x+1
  \end{aligned}$ & two & three \\\hline
  one & two & three \\\hline
\end{tabular}
\end{table}
\end{document}

I've made the following changes to your code to address your objectives:

  • Row 2, Column 1, contains an aligned environment (inside the $ ... $ math mode delimiters), with the & symbol used to align the equations on the respective equal signs.

  • There are new \caption and \label commands between \begin{table} and \begin{tabular}

  • There's a \centering directive immediately before the \begin{tabular} statement. Note that the caption will be centered automatically (unless it's longer than \textwidth).

share|improve this answer
add comment

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.