Graphics, Figures & TablesWhy the broken vertical bar in the right of my table?

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

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

Post by Singularity »

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

Code: Select all

\documentclass[fleqn,addpoints
,answers
]{exam}
\usepackage{amsfonts,amsmath,amssymb,amsthm,mathtools,commath}


\usepackage{tabularx}
\usepackage{multicol}       % For working in multiple columns
\usepackage{array}					% Provides for a more flexible array and tabular environment, like the column defs below
\usepackage{booktabs}				% For fancy stuff in arrays and tables
\usepackage{multicol}
\newcolumntype{L}{>{\begin{math}}l<{\end{math}}}%
\newcolumntype{C}{>{\begin{math}}c<{\end{math}}}%
\newcolumntype{R}{>{\begin{math}}r<{\end{math}}}%
%\newcolumntype{B}{>{\textbf\{}r<{\}}}    % NOT a working Bold column

\begin{document}


\begin{tabular}{|>{\bfseries}r|r|}
	\hline \\
	Horizontal Asymptote(s): & \hspace{3in} \\ \hline \\
	Vertical Asymptote(s):   &              \\ \hline \\
	Increasing:              &              \\ \hline \\
	Decreasing:              &              \\ \hline \\
	Concave up:              &              \\ \hline \\
	Concave down:            &              \\ \hline \\
	Relative max/min:        &              \\ \hline \\
	Inflections:             &              \\ \hline
\end{tabular}


\end{document}

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

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

Post by Johannes_B »

The reason is pretty simple: \\ (or \tabularnewline) ends the current line, which you obviously didn't want.

Code: Select all

\documentclass[fleqn,addpoints
	,answers
]{exam}
\usepackage{amsfonts,amsmath,amssymb,amsthm,mathtools,commath}


\usepackage{tabularx}
\usepackage{multicol}       % For working in multiple columns
\usepackage{array}                                      % Provides for a more flexible array and tabular environment, like the column defs below
\usepackage{booktabs}                           % For fancy stuff in arrays and tables
\usepackage{multicol}
\newcolumntype{L}{>{\begin{math}}l<{\end{math}}}%
\newcolumntype{C}{>{\begin{math}}c<{\end{math}}}%
\newcolumntype{R}{>{\begin{math}}r<{\end{math}}}%
							    %\newcolumntype{B}{>{\textbf\{}r<{\}}}    % NOT a working Bold column

\begin{document}
\begin{tabular}{|l|l|l|l|}
	1\\
	2&\\
	3&&\\
	4&&&\\
\end{tabular}

\begin{tabular}{|>{\bfseries}r|r|}
	\hline & \\
	Horizontal Asymptote(s): & \hspace{3in} \\ \hline & \\
	Vertical Asymptote(s):   &              \\ \hline & \\
	Increasing:              &              \\ \hline & \\
	Decreasing:              &              \\ \hline & \\
	Concave up:              &              \\ \hline & \\
	Concave down:            &              \\ \hline & \\
	Relative max/min:        &              \\ \hline & \\
	Inflections:             &              \\ \hline
\end{tabular}


\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: 156
Joined: Sat Jan 22, 2011 9:55 pm

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

Post by Singularity »

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).

Code: Select all

\documentclass[fleqn,addpoints
        ,answers
]{exam}
\usepackage{amsfonts,amsmath,amssymb,amsthm,mathtools,commath}


\usepackage{tabularx}
\usepackage{multicol}       % For working in multiple columns
\usepackage{array}                                      % Provides for a more flexible array and tabular environment, like the column defs below
\usepackage{booktabs}                           % For fancy stuff in arrays and tables
\usepackage{multicol}
\newcolumntype{L}{>{\begin{math}}l<{\end{math}}}%
\newcolumntype{C}{>{\begin{math}}c<{\end{math}}}%
\newcolumntype{R}{>{\begin{math}}r<{\end{math}}}%
\newcolumntype{B}{>{\bfseries}r<{}}     % Bold column

\begin{document}
\begin{tabular}{|B|r|}
	\hline 
	Horizontal Asymptote(s): & \hspace{3in} \\[1.5ex] \hline 
	Vertical Asymptote(s):   &              \\[1.5ex] \hline 
	Hole(s):                 &              \\[1.5ex] \hline 
	Increasing:              &              \\[1.5ex] \hline 
	Decreasing:              &              \\[1.5ex] \hline 
	Concave up:              &              \\[1.5ex] \hline 
	Concave down:            &              \\[1.5ex] \hline 
	Relative max/min:        &              \\[1.5ex] \hline 
	Inflections:             &              \\[1.5ex] \hline
\end{tabular}


\end{document}
I think that will be enough space for most students.
Post Reply