Graphics, Figures & Tables[SOLVED] Finishing hline after using newline in table

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
TheChefkoch
Posts: 2
Joined: Wed Jan 26, 2022 6:32 pm

[SOLVED] Finishing hline after using newline in table

Post by TheChefkoch »

Hi,

board newcomer here. I have the below table where the lower boundary \hline is not being drawn correctly. Any hints on how to resolve this?

Many thanks in advance for any guidance

Code: Select all

\documentclass{article}
\usepackage{multirow}
\begin{document}

\begin{table}[!htbp]
\centering
\begin{tabular}{|p{0.22\linewidth}|p{0.22\linewidth}||p{0.22\linewidth}|p{0.22\linewidth}|}
 \hline
 \multicolumn{2}{|l||}{\textbf{A}} & \multicolumn{2}{l|}{\textbf{B}} \\
 \hline
 \textbf{Heading1} & \textbf{Heading 2} & \textbf{Heading 3} & \textbf{Heading 4} \\
 \hline
 line \newline line \newline line
 & 
 line \newline line \newline line \newline line \newline line \newline line \newline line \newline line \newline line \newline line \newline 
 & 
 line \newline line \newline line \newline line \newline line \newline line \newline line \newline line \newline line \newline line \newline line &
\newline line \newline line \newline line \newline line \newline line \newline line
 \hline
\end{tabular}
\end{table}
\end{document}
Last edited by TheChefkoch on Thu Jan 27, 2022 1:28 pm, edited 1 time in total.

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

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

Finishing hline after using newline in table

Post by Bartman »

In the cell of the last row and column, the first \newline command prevents compilation. The missing \\ macro before the \hline command at the end of the table is another obstacle to an error-free LaTeX run.

Due to your table design I'd like to recommend the use of the tabularx and booktabs packages.
TheChefkoch
Posts: 2
Joined: Wed Jan 26, 2022 6:32 pm

Finishing hline after using newline in table

Post by TheChefkoch »

Bartman wrote:The missing \\ macro before the \hline command at the end of the table is another obstacle to an error-free LaTeX run.
Many thanks, this actually solved the issue (in my work-version)!
Post Reply