Graphics, Figures & TablesDifferent Number of Cells in each Table Row

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
drSlump
Posts: 4
Joined: Mon Feb 25, 2013 6:45 pm

Different Number of Cells in each Table Row

Post by drSlump »

Does anybody know how to fit the last two columns (H & I) of the last row within three columns (a & e & d)?

Code: Select all

\begin{table}[htb]
  \centering
  \begin{tabular}{lccc}\hline
    \multirow{2}{*}{Pos:}   a & b & c \\
    d & e & f \\ \hline\hline
    Loa:     H & I   \\ \hline
  \end{tabular}
\end{table}
Thanks a lot!
Last edited by localghost on Wed Mar 20, 2013 10:33 am, 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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Different Number of Cells in each Table Row

Post by localghost »

You are not using all columns that you declare in the table preamble. For the output you are after you can use a trick as shown in the below code. It relies on a second {tabular} inserted as inner table into the outer {tabular}. The output is attached.

Code: Select all

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{booktabs,multirow}

\begin{document}
  \begin{table}[!htb]
    \centering
    \begin{tabular}{lccc}\toprule
      \multirow{2}{*}{Pos:} & a & b & c \\
      & d & e & f \\ \midrule
      Loa: & \multicolumn{3}{c}{\begin{tabular}{cc} H & I \end{tabular}} \\ \bottomrule
    \end{tabular}
  \end{table}
\end{document}
Next time please prepare a self-contained and minimal example to give an adequate problem description.


Thorsten
Attachments
tmp.png
tmp.png (1.56 KiB) Viewed 7711 times
drSlump
Posts: 4
Joined: Mon Feb 25, 2013 6:45 pm

Re: Different Number of Cells in each Table Row

Post by drSlump »

thx a lot!
sorry but i am quite a new forum user.

can you tell me also how to achieve this result (different alignments)?
Attachments
Capture.PNG
Capture.PNG (3.16 KiB) Viewed 7707 times
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Different Number of Cells in each Table Row

Post by svend_tveskaeg »

That you are new to the forum has nothing to do with it.

Please post your try as a minimal working exmple.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Different Number of Cells in each Table Row

Post by localghost »

drSlump wrote:[…] can you tell me also how to achieve this result (different alignments)?
You are getting off the subject. But since we are here, we can talk about it. Just keep that in mind for the future. Nevertheless, you should meet Svend's request for a minimal example. As it stands now, your question sounds like "Do this for me". We appreciate questions more that present some code to be enhanced, not questions about writing code from scratch.
Post Reply