2

I am trying to put some equations inside an align environment in a cell inside a table. However, when I activate the \usepackage[table]{xcolor} option, my code inmediately crashes.

EDIT: I modified the question. Now, the code below works.

\documentclass{article}

% librería para definir funciones matemáticas
\usepackage{amsmath, amssymb}

% definiendo los colores
\usepackage[table]{xcolor} % con la opción para colorear las tablas

% Para las tablas
\usepackage{array}

\begin{document}
    \begin{table}
        \centering
        \begin{tabular}{%
                |
                >{\centering\arraybackslash}m{2cm}|%     Todo esto es para que centre horizontal
                >{\centering\arraybackslash}m{5cm}|%    y verticalmente en la celda
                >{\centering\arraybackslash}m{6cm}%
                |}
            \hline\hline
            \textbf{Caso}           & \textbf{Apoyo} & \textbf{Ecuaciones} \\ 
            \hline\hline
            Rodillo intermedio &
            & 
            {\makeatletter\CT@everycr{\the\everycr}
             %https://tex.stackexchange.com/questions/213342/problem-with-align-inside-tabular-environment-when-using-xcolor/213347#213347
                \begin{align*}
                      v_i(a) &= \Delta_a \\
                      v_{i+1}(a) &= \Delta_a \\
                      \theta_i(a) &= \theta_{i+1}(a) \\    
                      M_i(a) &= M_{i+1}(a) + m   
                \end{align*}
                \begin{center}
                    \hrulefill
                \end{center} 
                $R_y = V_{i+1}(a) - V_{i}(a) - f$ 
            }
        \\ \hline \hline
    \end{tabular}
\end{table}
\end{document}    
3
  • 3
  • 1
    as per the answer linked to by @UlrikeFischer, add \makeatletter\CT@everycr{\the\everycr}\makeatother in place of the % which follows the { right above \begin{align*}. Your question appears to be a duplicate indeed of the question whose answer Ulrike Fischer gave the link to.
    – user691586
    May 22 at 16:08
  • Thank you very much, you solved my problem! May 23 at 3:26

1 Answer 1

1

Your problem can also be avoided with use aligned math environment instead of align*. By using tabullaray` package for writing your table the MWE can be:

\documentclass{article}
% definiendo los colores
%\usepackage[table]{xcolor} % con la opción para colorear las tablas
% Para las tablas
\usepackage{tabularray}
% librería para definir funciones matemáticas
\UseTblrLibrary{amsmath}
\usepackage{amssymb}


\begin{document}
    \begin{table}
    \centering
\begin{tblr}{hlines, vlines,
             colspec = {Q[c, wd=2cm] X[0.8, c] X[c, mode=dmath]},
             row{1}  = {font=\bfseries, mode=text},
             rowsep=5pt
             }
Caso    &   Apoyo   &   Ecuaciones  \\
\SetCell[r=2]{h}    Rodillo intermedio 
        &   \SetCell[r=2]{c}               
                    &   \begin{aligned}
                    v_i(a)      & = \Delta_a        \\
                    v_{i+1}(a)  & = \Delta_a        \\
                    \theta_i(a) & = \theta_{i+1}(a) \\
                    M_i(a)      & = M_{i+1}(a) + m
                        \end{aligned}                       \\
        &           &   R_y = V_{i+1}(a) - V_{i}(a) - f     \\
\end{tblr}
    \end{table}
\end{document}

enter image description here

As you can see, I a wee bit change your table design.

You must log in to answer this question.

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