I am trying to display a table containing two columns. The first displays an identifier and the second is an equation for that identifier. The table would look like this (if equations were allowed in tables, but this is not the main problem).
\begin{tabular}{|c|c|}
\hline
Clause & Input\\
\hline
Clause \ref{one} & \begin{equation} part1 \rightarrow (part2 \rightarrow part3)\end{equation}\\
Clause \ref{two} & \begin{equation} part1' \rightarrow (part2' \rightarrow part3')\end{equation}\\
\hline
\end{tabular}
The problem, is that part1 is similar to part1', part2 to part2', ... and I would like those sub-parts of the equations to be aligned. That is, something closer to this:
\begin{align}
\cline{1-4}
\text{Clause} & Input & & \\
\cline{1-4}
\text{Clause \ref{one}} & part1 & \rightarrow (part2 & \rightarrow part3)\\
\text{Clause \ref{two}} & part1' & \rightarrow (part2' & \rightarrow part3')\\
\cline{1-4}
\end{align}
But with this option, difficult to reproduce the tabular{|c|c|} formatting...
Is there a way to do this properly ? Or combine these environments ? Note: I really want to avoid setting any specific sizes (minipages, ...)
[EDIT]: I have found a solution that works. There is probably a nicer solution, but here is the full code:
\newcolumntype{E}{>{\refstepcounter{equation}(\theequation)}c}
\begin{tabular}{|c|lllE|}
\hline
Clause & \multicolumn{4}{|c|}{$ctx$} \\
\hline
Clause \ref{clause:sas15:read} &
$v' = a[i]$ & $ \rightarrow ((v_a' = a[k_a'] \wedge i^{\#} = i \wedge v'^{\#} = v')$ & $ \rightarrow P_2^{\#}((k_a', v_a'), i^{\#}, v'^{\#}))$ & \label{eq:call:insts:read} \\
Clause \ref{clause:sas15:write} & $ a' = a[i \leftarrow v]$ & $ \rightarrow ((v_a' = a'[k_a'] \wedge i^{\#} = i \wedge v^{\#} = v)$ & $ \rightarrow P_2^{\#}((k_a', v_a'), i^{\#}, v^{\#})) $ & \label{eq:call:insts:write}\\
Clause \ref{clause:sas15:noarray} & $v' = 0$ & $ \rightarrow ((v_a' = a[k_a'] \wedge i^{\#} = i \wedge v'^{\#} = v )$ & $ \rightarrow P_2^{\#}((k_a', v_a'), i^{\#}, v'^{\#}))$ & \label{eq:call:insts:noarray}\\
\hline
\end{tabular}
I will keep the post open for a day in case someone has a nicer solution.
alignedat
fromamsmath
within in-line math ($...$
), which can be used within a table.\rightarrow
. Perhaps the edit I made makes things clearer. As foralignedat
, putting it into the tabular would not solve the problem: if the different equations are written in the same alignedat then there would be a mismatch with the Clause column.