If I put text into a table, the top of the characters are almost tutching the tip line in the cell, I can use \midrule instead which adds a small gap at the top of a cell, but then there are white gaps on the vertical lines of the table.
Thanks.
General ⇒ Text in tables butting up against the top line in a cell
NEW: TikZ book now 40% off at Amazon.com for a short time.

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Text in tables butting up against the top line in a cell
Build a minimal working example (MWE) that gives us an idea of the problem.
Best regards and welcome to the board
Thorsten¹
Best regards and welcome to the board
Thorsten¹
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Text in tables butting up against the top line in a cell
In professional tables there are no vertical lines, and the booktabs package does not support them, so leave them out.
Otherwise you can redefine \arraystretch or add a strut to the problematic cells.
Otherwise you can redefine \arraystretch or add a strut to the problematic cells.
Text in tables butting up against the top line in a cell
Thankslocalghost wrote:Build a minimal working example (MWE) that gives us an idea of the problem.
Best regards and welcome to the board
Thorsten¹
Code: Select all
\documentclass[11pt,a4paper]{article}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{| l | p{8cm}|}
\hline
\textbf{{\Large{Heading}}} & \textbf{{\Large{This text is touching the top line}}}\\
\hline
\textbf{hline} & this text is almost touching the top edge of the cell\\
\midrule
\textbf{Midrule} & The gap between the top of the text and the cell edge is
better, but now there are gaps in the vertical lines\\
\hline
\end{tabular}
\end{document}
The vertical lines are nessiserry to separate the table elements, otherwise it just looks like one line of text, Il look at arrayctretch.In professional tables there are no vertical lines, and the booktabs package does not support them, so leave them out.
Otherwise you can redefine \arraystretch or add a strut to the problematic cells.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Text in tables butting up against the top line in a cell
You can always put some horizontal space between the columns. The code below demonstrates two possible solutions each for stretching the row height and the space between columns.Hessiess wrote:[...] The vertical lines are nessiserry to separate the table elements, otherwise it just looks like one line of text, Il look at arrayctretch.
Code: Select all
\documentclass[11pt,a4paper]{article}
\usepackage{array,booktabs}
\usepackage[font=small,labelfont=bf]{caption}
\usepackage[margin=2cm]{geometry}
\setlength{\parindent}{0em}
\begin{document}
\begin{table}[!ht]
\centering
\renewcommand{\arraystretch}{1.2}
\begin{tabular}{|l|p{8cm}|} \hline
\textbf{{\Large{Heading}}} & \textbf{{\Large{This text is touching the top line}}} \\ \hline
\textbf{hline} & this text is almost touching the top edge of the cell \\ \hline
\textbf{hline} & The gap between the top of the text and the cell edge is better, but now there are gaps in the vertical lines \\ \hline
\end{tabular}
\caption{Table with stretched height of the rows}\label{tab:arraystretch}
\end{table}
\begin{table}[!ht]
\centering
\begin{tabular}{l@{\qquad}p{8cm}} \toprule
\textbf{{\Large{Heading}}} & \textbf{{\Large{This text is touching the top line}}} \\ \midrule
\textbf{midrule} & this text is almost touching the top edge of the cell \\ \midrule
\textbf{midrule} & The gap between the top of the text and the cell edge is better, but now there are gaps in the vertical lines \\ \bottomrule
\end{tabular}
\caption{Table with \textsf{booktabs} package and manual space between columns}\label{tab:booktabs-manual}
\end{table}
\begin{table}[!ht]
\centering
\setlength{\tabcolsep}{5mm}
\begin{tabular}{lp{8cm}} \toprule
\textbf{{\Large{Heading}}} & \textbf{{\Large{This text is touching the top line}}} \\ \midrule
\textbf{midrule} & this text is almost touching the top edge of the cell \\ \midrule
\textbf{midrule} & The gap between the top of the text and the cell edge is better, but now there are gaps in the vertical lines \\ \bottomrule
\end{tabular}
\caption{Table with \textsf{booktabs} package and fixed space between columns}\label{tab:booktabs-fixed}
\end{table}
\begin{table}[!ht]
\centering
\setlength{\extrarowheight}{2pt} % needs array package
\begin{tabular}{|l|p{8cm}|} \hline
\textbf{{\Large{Heading}}} & \textbf{{\Large{This text is touching the top line}}} \\ \hline
\textbf{hline} & this text is almost touching the top edge of the cell \\ \hline
\textbf{hline} & The gap between the top of the text and the cell edge is better, but now there are gaps in the vertical lines \\ \hline
\end{tabular}
\caption{Table with extra height for the rows}\label{tab:extrarowheight}
\end{table}
\end{document}
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10