3

I have a nice looking long table

enter image description here

However, I have no idea how to align the equations between these boxes to obtain something that looks like

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{thmtools}       
\usepackage{graphicx}
\usepackage{longtable}
\setlength\parindent{0pt}
\usepackage[linesnumbered,ruled]{algorithm2e}
\usepackage{array}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\usepackage{hyperref}
\usepackage{caption} 
\usepackage{cleveref}


\begin{document}
\begin{longtable}{ | M{5cm} | M{5cm}|}

    \hline
    \textbf{Name}
    & \textbf{Combiner equation}\\ 
    \hline

    {
        Chemical A278Aptx9
    }
    &{\begin{align*}
        A &= B \to C\\
        C &= D \to E
        \end{align*}
    }\\ 

    \hline
    {
        Chemical A279Apxdkcmasdl8
    } 
    & {\begin{align*}
        A &= B \to C \to E \to F\\
        C &= D \to E \to B
        \end{align*}
    }\\
    \hline
\end{longtable}
\end{document}
Fraïssé
  • 3,139

2 Answers2

2

Is this satisfactory? Note that it left aligns the equations, not at the alignment points you specified with &. So it only looks that well if the left side of &= doesn't change (or has the same width).

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{thmtools}       
\usepackage{graphicx}
\usepackage{longtable}
\setlength\parindent{0pt}
\usepackage[linesnumbered,ruled]{algorithm2e}
\usepackage{array}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\usepackage{hyperref}
\usepackage{caption} 
\usepackage{cleveref}

\makeatletter
\newcommand\fleqn[1][]{%
    \@fleqntrue%
    \ifx\relax#1\relax\else%
        \@mathmargin=#1\relax%
    \fi%
}
\makeatother


\begin{document}
\begin{longtable}{ | M{5cm} | M{5cm}|}

    \hline
    \textbf{Name}
    & \textbf{Combiner equation}\\ 
    \hline

    {
        Chemical A278Aptx9
    }
    &{\fleqn[0.5cm]\begin{align*}
        A &= B \to C\\
        C &= D \to E
        \end{align*}
    }\\ 

    \hline
    {
        Chemical A279Apxdkcmasdl8
    } 
    & {\fleqn[0.5cm]\begin{align*}
        A &= B \to C \to E \to F\\
        C &= D \to E \to B
        \end{align*}
    }\\
    \hline
\end{longtable}
\end{document}

enter image description here

Skillmon
  • 60,462
  • You already have +1 from me but I think you have to take care of first column too. The difficult part is what you did... But probably did not noticed first column. – koleygr Aug 18 '17 at 09:16
  • @koleygr I thought he wanted the first column and the heading of the second centered and only the align*s aligned. – Skillmon Aug 18 '17 at 09:19
  • I just look at his second image and suppose it is a modified version of the first... He could keep the first column without changing the picture... That's why I think you have to modify first column. But you can wait for his answer. – koleygr Aug 18 '17 at 09:24
1

Here is another option that works for someone who can not follow or modify @Skillmon's better solution if needed.

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{thmtools}       
\usepackage{graphicx}
\usepackage{longtable}
\setlength\parindent{0pt}
\usepackage[linesnumbered,ruled]{algorithm2e}
\usepackage{array}
\newcolumntype{M}[1]{>{\raggedright\arraybackslash} m{#1}}
\usepackage{hyperref}
\usepackage{caption} 
\usepackage{cleveref}


\begin{document}
\begin{longtable}{ | M{5cm} | M{5cm}|}

    \hline
    \multicolumn{1}{|c|}{\textbf{Name}}
    & \multicolumn{1}{c|}{\textbf{Combiner equation}}\\ 
    \hline
    {
        Chemical A278Aptx9
    }
    & {\begin{align*}
        A &= B \to C\\
        C &= D \to E \phantom{\to F \to G}
        \end{align*}
    }\\ 
    \hline
    {
        Chemical A279Apxdkcmasdl8
    }
    & {\begin{align*}
        A &= B \to C \to E \to F\\
        C &= D \to E \to B
        \end{align*}
    }\\
    \hline
\end{longtable}
\end{document}

Initially I thought I don't have to use phantom and had provide a comment for such solution. But finally I realized I can not do it without phantom but it is an easy and not too experienced solution for the specific problem.

The result is here:

enter image description here but need more typing (longtable means many values) and is not really efficient.

koleygr
  • 20,105