LaTeX forum ⇒ Graphics, Figures & TablesWhy the broken vertical bar in the right of my table? Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
Singularity
Posts: 152
Joined: Sat Jan 22, 2011 9:55 pm

Why the broken vertical bar in the right of my table?

Postby Singularity » Sun Nov 15, 2015 3:28 am

The rightmost vertical bar in my table is broken (see attachment). Why?
MWE.pdf
(16.96 KiB) Downloaded 74 times


  1. \documentclass[fleqn,addpoints
  2. ,answers
  3. ]{exam}
  4. \usepackage{amsfonts,amsmath,amssymb,amsthm,mathtools,commath}
  5.  
  6.  
  7. \usepackage{tabularx}
  8. \usepackage{multicol} % For working in multiple columns
  9. \usepackage{array} % Provides for a more flexible array and tabular environment, like the column defs below
  10. \usepackage{booktabs} % For fancy stuff in arrays and tables
  11. \usepackage{multicol}
  12. \newcolumntype{L}{>{\begin{math}}l<{\end{math}}}%
  13. \newcolumntype{C}{>{\begin{math}}c<{\end{math}}}%
  14. \newcolumntype{R}{>{\begin{math}}r<{\end{math}}}%
  15. %\newcolumntype{B}{>{\textbf\{}r<{\}}} % NOT a working Bold column
  16.  
  17. \begin{document}
  18.  
  19.  
  20. \begin{tabular}{|>{\bfseries}r|r|}
  21. \hline \\
  22. Horizontal Asymptote(s): & \hspace{3in} \\ \hline \\
  23. Vertical Asymptote(s): & \\ \hline \\
  24. Increasing: & \\ \hline \\
  25. Decreasing: & \\ \hline \\
  26. Concave up: & \\ \hline \\
  27. Concave down: & \\ \hline \\
  28. Relative max/min: & \\ \hline \\
  29. Inflections: & \\ \hline
  30. \end{tabular}
  31.  
  32.  
  33. \end{document}

Tags:

User avatar
Johannes_B
Site Moderator
Posts: 3904
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Sun Nov 15, 2015 12:16 pm

The reason is pretty simple: \\ (or \tabularnewline) ends the current line, which you obviously didn't want.
  1. \documentclass[fleqn,addpoints
  2. ,answers
  3. ]{exam}
  4. \usepackage{amsfonts,amsmath,amssymb,amsthm,mathtools,commath}
  5.  
  6.  
  7. \usepackage{tabularx}
  8. \usepackage{multicol} % For working in multiple columns
  9. \usepackage{array} % Provides for a more flexible array and tabular environment, like the column defs below
  10. \usepackage{booktabs} % For fancy stuff in arrays and tables
  11. \usepackage{multicol}
  12. \newcolumntype{L}{>{\begin{math}}l<{\end{math}}}%
  13. \newcolumntype{C}{>{\begin{math}}c<{\end{math}}}%
  14. \newcolumntype{R}{>{\begin{math}}r<{\end{math}}}%
  15. %\newcolumntype{B}{>{\textbf\{}r<{\}}} % NOT a working Bold column
  16.  
  17. \begin{document}
  18. \begin{tabular}{|l|l|l|l|}
  19. 1\\
  20. 2&\\
  21. 3&&\\
  22. 4&&&\\
  23. \end{tabular}
  24.  
  25. \begin{tabular}{|>{\bfseries}r|r|}
  26. \hline & \\
  27. Horizontal Asymptote(s): & \hspace{3in} \\ \hline & \\
  28. Vertical Asymptote(s): & \\ \hline & \\
  29. Increasing: & \\ \hline & \\
  30. Decreasing: & \\ \hline & \\
  31. Concave up: & \\ \hline & \\
  32. Concave down: & \\ \hline & \\
  33. Relative max/min: & \\ \hline & \\
  34. Inflections: & \\ \hline
  35. \end{tabular}
  36.  
  37.  
  38. \end{document}


There might be a nicer way to achieve what you want.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Singularity
Posts: 152
Joined: Sat Jan 22, 2011 9:55 pm

Postby Singularity » Sun Nov 15, 2015 6:31 pm

IOW, \hline does not need a newline. You're right, there are vertical cell spacing commands in the tabularx class which would be better, but I just went with this solution (I also got the column definition working).

  1. \documentclass[fleqn,addpoints
  2. ,answers
  3. ]{exam}
  4. \usepackage{amsfonts,amsmath,amssymb,amsthm,mathtools,commath}
  5.  
  6.  
  7. \usepackage{tabularx}
  8. \usepackage{multicol} % For working in multiple columns
  9. \usepackage{array} % Provides for a more flexible array and tabular environment, like the column defs below
  10. \usepackage{booktabs} % For fancy stuff in arrays and tables
  11. \usepackage{multicol}
  12. \newcolumntype{L}{>{\begin{math}}l<{\end{math}}}%
  13. \newcolumntype{C}{>{\begin{math}}c<{\end{math}}}%
  14. \newcolumntype{R}{>{\begin{math}}r<{\end{math}}}%
  15. \newcolumntype{B}{>{\bfseries}r<{}} % Bold column
  16.  
  17. \begin{document}
  18. \begin{tabular}{|B|r|}
  19. \hline
  20. Horizontal Asymptote(s): & \hspace{3in} \\[1.5ex] \hline
  21. Vertical Asymptote(s): & \\[1.5ex] \hline
  22. Hole(s): & \\[1.5ex] \hline
  23. Increasing: & \\[1.5ex] \hline
  24. Decreasing: & \\[1.5ex] \hline
  25. Concave up: & \\[1.5ex] \hline
  26. Concave down: & \\[1.5ex] \hline
  27. Relative max/min: & \\[1.5ex] \hline
  28. Inflections: & \\[1.5ex] \hline
  29. \end{tabular}
  30.  
  31.  
  32. \end{document}


I think that will be enough space for most students.


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 9 guests