Graphics, Figures & TablesAligning mathematical equations vertically in a table - Overleaf

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
joeTex
Posts: 6
Joined: Mon Sep 23, 2019 11:58 pm

Aligning mathematical equations vertically in a table - Overleaf

Post by joeTex »

Hi

I would like to align equations - which are separately inserted into table cells - vertically along the red line - as shown in the figure below:
pic1.jpg
pic1.jpg (141.03 KiB) Viewed 6924 times
The above is a small excerpt of a large table with multiple rows and columns (text columns to the left and right of the image too) - I have tried a multitude of methods, but have not been successful. I am using Overleaf.

Has anybody had success in implementing this? If so, I would really appreciate the assistance of the community by means of a small minimal working code example?

Thanks a lot

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

Aligning mathematical equations vertically in a table - Overleaf

Post by Bartman »

Why don't you show us one of your attempts using a Infominimal working example so that we don't have to enter the content of the table shown?
joeTex
Posts: 6
Joined: Mon Sep 23, 2019 11:58 pm

Aligning mathematical equations vertically in a table - Overleaf

Post by joeTex »

Code: Select all

Code, edit and compile here:
\documentclass[a4paper, 11pt, oneside]{scrbook}
\usepackage{adjustbox}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{makecell}
% ------------------- Begin the document -----------------------------
\begin{document}
\begin{table}[h!]
\centering
\begin{adjustbox}{center}
\begin{tabular}{c c c c c}
x &$b_{2}$ &20.25 &\multirow{4}{5cm}{\parbox{\begin{align*}
0.91 \leq &\Delta x \leq 3.30 \\
1.50 \leq &\Delta x \leq 1.83 \\
&\Delta x \leq 0.34 \\
2.17 \leq &\Delta x \leq 2.17
\end{align*}
}} & 12 \\
x &$r_{n}$ &55 & & 10 \\
x &$\Delta r_{n}$ &0 & & 4 \\
x &$r_{1}$ &105.45 & & 8
\end{tabular}
\end{adjustbox}
\end{table}%
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
@Bartman; Thanks for the reply - see the MWE above. I have made it work partially; however there is an error (which I do not understand) and an offset in the table column which I cant seem to remove (most probably due to my limited experience). Is there any other method which would work better, or did I just miss the boat completely on this one?
Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

Aligning mathematical equations vertically in a table - Overleaf

Post by Bartman »

The first required argument of the \parbox command expects a length.

My proposition:

Code: Select all

Code, edit and compile here:
\documentclass[
% a4paper, fontsize=11pt,% default setting
oneside
]{scrbook}
\usepackage{amsmath}
\usepackage{siunitx}% provides S column type
% Read the manual of the array package to find out,
% how you can use >{} and <{} to set declarations.
% siunitx loads array.
\newcolumntype{C}{>{$}c<{$}}
\begin{document}
\begin{table}[htbp]
\centering
\begin{tabular}{
*2C
S[table-format=3.2]
C@{\;$\Delta x\leq$\;}
C
S[table-format=2]
}
x & b_2 & 20.25 & 0.91 \leq & 3.30 & 12 \\
x & r_n & 55 & 1.50 \leq & 1.83 & 10 \\
x & \Delta r_n & 0 & & 0.34 & 4 \\
x & r_1 & 105.45 & 2.17 \leq & 2.17 & 8
\end{tabular}
\end{table}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Last edited by Bartman on Mon Aug 03, 2020 2:49 am, edited 1 time in total.
joeTex
Posts: 6
Joined: Mon Sep 23, 2019 11:58 pm

Aligning mathematical equations vertically in a table - Overleaf

Post by joeTex »

@Bartman: Thanks a lot, I was also thinking of physically splitting the column into two separate columns then to right and left align the adjacent cells to simulate a merged & aligned column. Unless somebody else has another method to achieve the same result - I suppose this will do just fine.
joeTex
Posts: 6
Joined: Mon Sep 23, 2019 11:58 pm

Aligning mathematical equations vertically in a table - Overleaf

Post by joeTex »

I played with this a little bit. I modified the code from @Bartman a little bit, just to make it a little more simple to use (well, according to my limited experience using this platform). See below:

Code: Select all

Code, edit and compile here:
\documentclass[
% a4paper, fontsize=11pt,% default setting
oneside
]{scrbook}
\usepackage{amsmath}
\usepackage{siunitx}% provides S column type
% Read the manual of the array package to find out,
% how you can use >{} and <{} to set declarations.
% siunitx loads array.
\newcolumntype{C}{>{$}c<{$}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%% Bartman's method, changed a bit - below %%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{table}[htbp]
\centering
\begin{tabular}{
c
c %*2C
c %S[table-format=3.5]
C@{\;$\Delta x\leq$\;}
c %C
c %S[table-format=3]
}
x & $b_2$ & 20.25 & 0.91 \leq & 3.30 & 12 \\
x & $r_n$ & 55 & 1.50 \leq & 1.83 & 10 \\
x & $\Delta r_n$ & 0 & & 0.34 & 4 \\
x & $r_1$ & 105.45 & 2.17 \leq & 2.17 & 8
\end{tabular}
\end{table}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
I also tried to just shift the adjacent columns to "brute force" the alignment - I think I was successful (or at least partially), this will also allow for alignment between different kinds of markers, see below:

Code: Select all

Code, edit and compile here:
\documentclass[
% a4paper, fontsize=11pt,% default setting
oneside
]{scrbook}
\usepackage{amsmath}
\usepackage{siunitx}% provides S column type
% Read the manual of the array package to find out,
% how you can use >{} and <{} to set declarations.
% siunitx loads array.
\newcolumntype{R}{>{\raggedright\arraybackslash}r@{\hspace{3pt}}} %New column type, change right spacing and left align
\newcolumntype{L}{>{\raggedleft\arraybackslash}l} %New column type, right align, no change in left spacing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%% My method - below %%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{table}[htbp]
\centering
\begin{tabular}{
c
c %*2C
c %S[table-format=3.5]
R %C@{\;$\Delta x\leq$\;}
L %c %C
c %S[table-format=3]
}
x & $b_2$ & 20.25 & $0.91 \leq$ & $\Delta x\leq 3.30$ & 12 \\
x & $r_n$ & 55 & $1.50 \leq$ & $\Delta x\leq 1.83$ & 10 \\
x & $\Delta r_n$ & 0 & & $\Delta x\leq 0.34$ & 4 \\
x & $r_1$ & 105.45 & $2.17 \leq$ & $\Delta x\leq 2.17$ & 8
\end{tabular}
\end{table}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
But yes, several methods to achieve the same goal - some more elegant than others, but still - thanks for the input @Bartman, it is really highly appreciated.
Last edited by joeTex on Mon Aug 03, 2020 6:30 pm, edited 1 time in total.
Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

Aligning mathematical equations vertically in a table - Overleaf

Post by Bartman »

In the second example the beginning of the document environment is missing.
hankr123
Posts: 1
Joined: Sat Sep 12, 2020 7:13 pm

Aligning mathematical equations vertically in a table - Overleaf

Post by hankr123 »

Much obliged, I was additionally considering truly parting the section into two separate segments at that point to both ways adjust the nearby cells to reenact a blended and adjusted segment. Except if another person has another strategy to accomplish a similar outcome - I guess this will do fine and dandy.
[url=adobezii.online/]adobe universal patcher[/url]
Post Reply