LaTeX forum ⇒ Graphics, Figures & TablesAligning mathematical equations vertically in a table - Overleaf Topic is solved

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

Aligning mathematical equations vertically in a table - Overleaf

Postby joeTex » Sun Aug 02, 2020 9:41 pm

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 312 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

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

Postby Bartman » Sun Aug 02, 2020 11:40 pm

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

Postby joeTex » Mon Aug 03, 2020 1:16 am

Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \documentclass[a4paper, 11pt, oneside]{scrbook}
  2. \usepackage{adjustbox}
  3. \usepackage{amsmath}
  4. \usepackage{multirow}
  5. \usepackage{makecell}
  6.  
  7.  
  8. % ------------------- Begin the document -----------------------------
  9. \begin{document}
  10.  
  11. \begin{table}[h!]
  12. \centering
  13. \begin{adjustbox}{center}
  14. \begin{tabular}{c c c c c}
  15. x &$b_{2}$ &20.25 &\multirow{4}{5cm}{\parbox{\begin{align*}
  16. 0.91 \leq &\Delta x \leq 3.30 \\
  17. 1.50 \leq &\Delta x \leq 1.83 \\
  18. &\Delta x \leq 0.34 \\
  19. 2.17 \leq &\Delta x \leq 2.17
  20. \end{align*}
  21. }} & 12 \\
  22. x &$r_{n}$ &55 & & 10 \\
  23. x &$\Delta r_{n}$ &0 & & 4 \\
  24. x &$r_{1}$ &105.45 & & 8
  25. \end{tabular}
  26. \end{adjustbox}
  27. \end{table}%
  28.  
  29. \end{document}


@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: 113
Joined: Fri Jan 03, 2020 2:39 pm

Postby Bartman » Mon Aug 03, 2020 2:11 am

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

My proposition:

Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \documentclass[
  2. % a4paper, fontsize=11pt,% default setting
  3. oneside
  4. ]{scrbook}
  5.  
  6. \usepackage{amsmath}
  7. \usepackage{siunitx}% provides S column type
  8.  
  9. % Read the manual of the array package to find out,
  10. % how you can use >{} and <{} to set declarations.
  11. % siunitx loads array.
  12. \newcolumntype{C}{>{$}c<{$}}
  13.  
  14. \begin{document}
  15. \begin{table}[htbp]
  16. \centering
  17. \begin{tabular}{
  18. *2C
  19. S[table-format=3.2]
  20. C@{\;$\Delta x\leq$\;}
  21. C
  22. S[table-format=2]
  23. }
  24. x & b_2 & 20.25 & 0.91 \leq & 3.30 & 12 \\
  25. x & r_n & 55 & 1.50 \leq & 1.83 & 10 \\
  26. x & \Delta r_n & 0 & & 0.34 & 4 \\
  27. x & r_1 & 105.45 & 2.17 \leq & 2.17 & 8
  28. \end{tabular}
  29. \end{table}
  30. \end{document}
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

Postby joeTex » Mon Aug 03, 2020 2:46 am

@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

Postby joeTex » Mon Aug 03, 2020 11:29 am

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] [Expand/Collapse] [Download] ({untitled.tex})
  1. \documentclass[
  2. % a4paper, fontsize=11pt,% default setting
  3. oneside
  4. ]{scrbook}
  5.  
  6. \usepackage{amsmath}
  7. \usepackage{siunitx}% provides S column type
  8.  
  9. % Read the manual of the array package to find out,
  10. % how you can use >{} and <{} to set declarations.
  11. % siunitx loads array.
  12. \newcolumntype{C}{>{$}c<{$}}
  13.  
  14. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  15. %%%%%%%%%%%% Bartman's method, changed a bit - below %%%%%%%%%%%%%%%%
  16. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  17.  
  18. \begin{document}
  19. \begin{table}[htbp]
  20. \centering
  21. \begin{tabular}{
  22. c
  23. c %*2C
  24. c %S[table-format=3.5]
  25. C@{\;$\Delta x\leq$\;}
  26. c %C
  27. c %S[table-format=3]
  28. }
  29. x & $b_2$ & 20.25 & 0.91 \leq & 3.30 & 12 \\
  30. x & $r_n$ & 55 & 1.50 \leq & 1.83 & 10 \\
  31. x & $\Delta r_n$ & 0 & & 0.34 & 4 \\
  32. x & $r_1$ & 105.45 & 2.17 \leq & 2.17 & 8
  33. \end{tabular}
  34. \end{table}
  35.  
  36. \end{document}


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] [Expand/Collapse] [Download] ({untitled.tex})
  1. \documentclass[
  2. % a4paper, fontsize=11pt,% default setting
  3. oneside
  4. ]{scrbook}
  5.  
  6. \usepackage{amsmath}
  7. \usepackage{siunitx}% provides S column type
  8.  
  9. % Read the manual of the array package to find out,
  10. % how you can use >{} and <{} to set declarations.
  11. % siunitx loads array.
  12.  
  13. \newcolumntype{R}{>{\raggedright\arraybackslash}r@{\hspace{3pt}}} %New column type, change right spacing and left align
  14. \newcolumntype{L}{>{\raggedleft\arraybackslash}l} %New column type, right align, no change in left spacing
  15.  
  16.  
  17. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  18. %%%%%%%%%%%%%%%%%%%%%%% My method - below %%%%%%%%%%%%%%%%%%%%%%%%%%%
  19. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  20.  
  21. \begin{document}
  22. \begin{table}[htbp]
  23. \centering
  24. \begin{tabular}{
  25. c
  26. c %*2C
  27. c %S[table-format=3.5]
  28. R %C@{\;$\Delta x\leq$\;}
  29. L %c %C
  30. c %S[table-format=3]
  31. }
  32. x & $b_2$ & 20.25 & $0.91 \leq$ & $\Delta x\leq 3.30$ & 12 \\
  33. x & $r_n$ & 55 & $1.50 \leq$ & $\Delta x\leq 1.83$ & 10 \\
  34. x & $\Delta r_n$ & 0 & & $\Delta x\leq 0.34$ & 4 \\
  35. x & $r_1$ & 105.45 & $2.17 \leq$ & $\Delta x\leq 2.17$ & 8
  36. \end{tabular}
  37. \end{table}
  38.  
  39. \end{document}


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: 113
Joined: Fri Jan 03, 2020 2:39 pm

Postby Bartman » Mon Aug 03, 2020 5:25 pm

In the second example the beginning of the document environment is missing.

hankr123
Posts: 1
Joined: Sat Sep 12, 2020 7:13 pm

Postby hankr123 » Sat Sep 12, 2020 7:16 pm

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]


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 4 guests