2

So, I'm trying to make a column in my tabular environment be in \begin{align*} \end{align*}.

Been trying a few different things, but, I'm still a bit new to LaTeX. I'm still playing around a lot trying to learn. Therefore some short explanation on where I went wrong would be really nice.

So here is the thing I ended up with:

\usepackage{amsmath}
\usepackage{array} %I think these two are the only relevant packages for this problem.

\newcommand{\eq}[1]{\begin{align*}#1\end{align*}} %Redefining align* sens >{dec}<{dec}
%don't like extra {}

\begin{document}
\begin{table}

\caption{some cool caption} %guess this isn't relevant but..

\begin{tabular*}{\textwidth} %Having a twocolumn doc so...
{|>{$}l<{$}|
                         *{2}{m{0.28\textwidth}|
                            >{\eq\bgroup}m{0.129\textwidth}<{\egroup}|}}

%The last column is where the magic is supposed to happen
%I'm also using multicolumns, not that I think it matters.
\frac{Cool}{equations} & Cool text & cool text & \frac{cool equations}{Broken column :'(
} \\
The coolness will be repeated for a few rows    \\

\end{tabular*}
\end{table}
\end{document}

Is it just easier to just use \eq in every column? The errors I get is: Missing } inserted. & \frac; Missing $ inserted.; Extra }, or forgotten $.; Any help is welcome, and if the problem is not solvable maybe just a line or two where I went wrong in my thinking would really help me learn.

Best regards EDIT: Adding what my code actually looks like and the result it produces. My issue is that some columns look really ugly and I would like the second line of the cell to be centered (Which I assume the align* environment would do). I tried to use the \newcolumntype{C}{>{$}c<{$}}, but, it only gave me errors when I then changed >{$}m<{$} for C, or, just changed m to c. I hope this helps in clarifying what I'm trying to do.

\noindent%
\begin{table}[!b] 
\begin{center}
\onecolumn
\caption{Tables showing the different outcomes from changing the retention (re) and $k_{3}$ parameters in the aging model of \textit{S. cerevisiae}.
The model was constructed using the \citetitle{math} program with \citetitle{sbml}.}
\label{table:daughter}
\end{center}
    \begin{tabular*}{\textwidth}{|>{$}l<{$}|
                             *{2}{m{0.28\textwidth}|
                                >{$}m{0.129\textwidth}<{$}|}}
    \cline{2-5}
\multicolumn{1}{c|}{}   
    & \multicolumn{4}{c|}{Daughter}                                         \\
    \cline{2-5}
\multicolumn{1}{c|}{}
    &   \multicolumn{2}{c|}{$re=0$} 
            &   \multicolumn{2}{c|}{$re=0.875$}                             \\ 
    \hline
k_{3}=0
    &   \smallskip
        \includegraphics[width=\hsize]{daughterC1,0.jpg}
        &   \frac{\text{Number of division}}{\text{3 time units}}=\linebreak
                =\frac{25}{3}=8.\overline{3}\approx8
            &   \smallskip
                \includegraphics[width=\hsize]{daughterC2,0.jpg}
                &   \frac{\text{Number of division}}{\text{3 time units}}=\linebreak
                =\frac{25}{3}=8.\overline{3}\approx8 \\
    \hline
k_{3}=1.6
    &
        \smallskip
            \includegraphics[width=\hsize]{daughterC1,16.jpg}
            & \frac{\text{Number of division}}{\text{3 time units}}=\linebreak
                =\frac{14}{3}=4.\overline{6}\approx4.7  
                &   \smallskip
                    \includegraphics[width=\hsize]{daughterC2,16.jpg}
                & \frac{\text{Number of division}}{\text{3 time units}}=\linebreak
                =\frac{16}{3}=5.\overline{3}\approx5\\
    \hline
k_{3}=2.3
    &
        \smallskip  
            \includegraphics[width=\hsize]{daughterC1,25.jpg}
                &\frac{\text{Number of division}}{\text{3 time units}}=\linebreak
                =\frac{1}{3}=0.\overline{3}
                    & \smallskip
                    \includegraphics[width=\hsize]{daughterC2,25.jpg}
                    & \frac{\text{Number of division}}{\text{3 time units}}=\linebreak
                    =\frac{1}{3}=0.\overline{3}\\
    \hline
    \end{tabular*}
        \begin{tabular*}{\textwidth}{|>{$}l<{$}|
                             *{2}{m{0.28\textwidth}|>{$}m{0.129\textwidth}<{$}|}}
    \cline{2-5}
\multicolumn{1}{c|}{}    
    & \multicolumn{4}{c|}{Mother}                                         \\
    \cline{2-5}
\multicolumn{1}{c|}{}
    &   \multicolumn{2}{c|}{$re=0$} 
            &   \multicolumn{2}{c|}{$re=0.875$}                             \\ 
    \hline
k_{3}=0
    &   \smallskip
        \includegraphics[width=\hsize]{motherC1,0.jpg}
        &   \frac{\text{Number of division}}{\text{3 time units}}=\linebreak
            \frac{53}{3}=17.\overline{3}\approx17
            &   \smallskip
                \includegraphics[width=\hsize]{motherC2,0.jpg}
                &   \frac{\text{Number of division}}{\text{3 time units}}=\linebreak
                \frac{53}{3}=17.\overline{3}\approx17                   \\
    \hline
k_{3}=1.6
    &
        \smallskip
            \includegraphics[width=\hsize]{motherC1,16.jpg}
            & \frac{\text{Number of division}}{\text{3 time units}}=\linebreak
              \frac{6}{3}=2 
                &   \smallskip
                    \includegraphics[width=\hsize]{motherC2,16.jpg}
                & \frac{\text{Number of division}}{\text{3 time units}}=\linebreak
                   \frac{3}{3}=1 \\
    \hline
k_{3}=2.3
    &
        \smallskip  
            \includegraphics[width=\hsize]{motherC1,23.jpg}
                & \frac{\text{Number of division}}{\text{3 time units}}=\linebreak
                =\frac{1}{3}=0.\overline{3}
                    & \smallskip
                    \includegraphics[width=\hsize]{motherC2,23.jpg}
                    & \frac{\text{Number of division}}{\text{3 time units}}=\linebreak
                    =\frac{1}{3}=0.\overline{3} \\
    \hline
    \end{tabular*}

\end{table}
\twocolumn

[What it looks like[1]

3
  • I am not sure this will work at all even outside of a tabular environment
    – user31729
    Oct 3 '15 at 8:26
  • You shouldn't be using align: just math mode is sufficient in the formula columns.
    – egreg
    Oct 3 '15 at 11:01
  • Ye I did that before, but, I thought that it was a bit ugly in some of the cells. But then again, maybe I should just be less picky with the esthetics.
    – Baraliuh
    Oct 3 '15 at 11:05
1

Your definition of column types have some mismatch, the following work fine:

\documentclass[a4paper,11pt]{report}
\usepackage{amsmath}
\usepackage{array,mdwtab} %I think these two are the only relevant packages for this problem.

    \begin{document}
        \begin{table}[h]\centering
        \renewcommand{\arraystretch}{1.5}
    \caption{some cool caption} %guess this isn't relevant but..
        \label{tab:important}
    \begin{tabular}{|Ml|% with use of mdwtab 
                    *{2}{m{0.28\textwidth}|}
                     Ml|}
        \hline %just for better see table ...
    %The last column is where the magic is supposed to happen
    %I'm also using multicolumns, not that I think it matters.
    \frac{Cool}{equations} 
        & Cool text 
            & cool text 
                & \frac{cool\ equations}{Broken\ column} \\
        \hline% 
    \multicolumn{4}{|c|}{with use of mdwtab}    \\
        \hline
    \end{tabular}
        \\
    \begin{tabular}{|>{$}l<{$}|% 
                    *{2}{m{0.28\textwidth}|}
                     >{$}l<{$}|}
        \hline %just for better see table ...
    %The last column is where the magic is supposed to happen
    %I'm also using multicolumns, not that I think it matters.
    \frac{Cool}{equations}
        & Cool text
            & cool text
                & \frac{cool\ equations}{Broken\ column} \\
        \hline%
    \multicolumn{4}{|c|}{without use of mdwtab}    \\
        \hline
    \end{tabular}
        \\
    \begin{tabular*}{\textwidth}{|>{$}l<{$}|% without use of mdwtab
                    *{2}{m{0.28\textwidth}|}
                     >{$}l<{$}|}
        \hline %just for better see table ...
    %The last column is where the magic is supposed to happen
    %I'm also using multicolumns, not that I think it matters.
    \frac{Cool}{equations}
        & Cool text
            & cool text
                & \frac{cool\ equations}{Broken\ column} \\
        \hline%
    \multicolumn{4}{|c|}{with use of tabular*}    \\
        \hline
    \end{tabular*}

enter image description here

If you like to have displayed equations, than is sufficient to say >{$\displaystyle}l<{$}:

\documentclass[a4paper,11pt]{report}
\usepackage{amsmath}
\usepackage{array} 

\begin{document}
    \begin{table}[h]\centering
    \renewcommand{\arraystretch}{2}
\caption{some cool caption} %guess this isn't relevant but..
    \label{tab:important}
\begin{tabular*}{\textwidth}{|>{$\displaystyle}l<{$}|% 
                *{2}{p{0.2\textwidth}|}
                 >{$\displaystyle}l<{$}|}
\frac{Cool}{equations}
    & Cool text
        & cool text
            & \frac{cool\ equations}{Broken\ column} 
\end{tabular*}
    \end{table}
\end{document}

enter image description here

If you need structure in cells provided with amsmath's environments as are multi line equation, than is better (to my opinion) to write in cell (with colum type for example >{$}m{\0.2\textwidth}<{$}) something like:

\documentclass[a4paper,11pt]{report}
\usepackage{amsmath}
\usepackage{array} 

\begin{document}
    \begin{table}[h]\centering
    \renewcommand{\arraystretch}{2}
\caption{some cool caption} %guess this isn't relevant but..
    \label{tab:important}
\begin{tabular*}{\textwidth}{|>{$\displaystyle}l<{$}|% 
                *{2}{p{0.2\textwidth}|}
                 >{$\displaystyle}l<{$}|}
\frac{Cool}{equations}
    & Cool text
        & cool text
            & \begin{aligned}
                x & = \frac{cool\ equations}{Broken\ column}\\
                  & = second\ line\ of\ equation\end{aligned} 
\end{tabular*}
    \end{table}

enter image description here

1
  • Hi! Thank you for taking your time and helping me. I will scrutinize your solutions, the packages you suggest and test it out/play around with it! I have also realized that it would probably just have been smarter of me to post what I'm actually doing, even thou I thought it would be a---too big and too messy post then.
    – Baraliuh
    Oct 3 '15 at 11:01
0

If you do

\newcommand{\eq}[1]{...}

you can't call it like

\eq\bgroup ... \egroup

under any circumstance.

You can use the collcell package and not align* (which would add huge spaces above and below it), but a centered aligned.

\documentclass{article}
\usepackage{amsmath}
\usepackage{array} %I think these two are the only relevant packages for this problem.
\usepackage{collcell}

\newcommand{\eq}[1]{\centering$\begin{aligned}#1\end{aligned}$}

\begin{document}
\begin{table*}

\caption{some cool caption} %guess this isn't relevant but..

\begin{tabular}{
  |>{$}l<{$}|
   >{\collectcell\eq}m{0.3\textwidth}<{\endcollectcell}|
}
\frac{Cool}{equations} & \frac{cool equations}{Broken column} \tabularnewline
\end{tabular}
\end{table*}
\end{document}

Note that you are using the * the other way around: for a one column table in a two column setting, use table*. The tabular* environment is for a different thing.

It's still not clear to me what you hope to fit in 13% of the text width.

enter image description here

1
  • Hi, Thank you for taking your time to help me. I have posten the original code I'm working with and added a picture of the issue as well as some text to clarify!
    – Baraliuh
    Oct 3 '15 at 10:56

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.