Graphics, Figures & TablesHorizontal Line affects Table Alignment

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
heavytull
Posts: 16
Joined: Wed Feb 08, 2012 9:38 pm

Horizontal Line affects Table Alignment

Post by heavytull »

I'm trying to align a tabular with a picture relative to top. It seems that the presence of an \hline at the top of the table changes alignment rules.
here is an example:

Code: Select all

\documentclass[12pt,a4paper,sans]{article}
\usepackage[demo]{graphicx}

\begin{document}
\raisebox{-\totalheight}{\includegraphics[width=64pt]{test}}
\begin{tabular}[t]{p{8cm}}
\hline    % the presence of this command makes alignment as wanted
          % but when removed, the alignment is done with the second
          % line of the table
Some text \\
\hline
\rule{6cm}{0.25ex}\\
Some text \\
\end{tabular}
\end{document}
Last edited by localghost on Thu May 03, 2012 9:42 am, edited 2 times 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

justdeath
Posts: 69
Joined: Mon Sep 05, 2011 10:27 am

Horizontal Line affects Table Alignment

Post by justdeath »

Hi, you are doing it wrong:

Code: Select all

\documentclass[12pt,a4paper]{article}
\usepackage{graphicx}

\begin{document}
\begin{tabular}{p{0.2\textwidth}|p{0.7\textwidth}}
\vspace{0pt}\includegraphics[scale=0.6]{logos} & Some text
\end{tabular}
\end{document}
Both columns should be paragraphs "p", and \vspace{0pt} before the graphic include.
Post Reply