Graphics, Figures & TablesFit a multirow in a Table

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Diogo Remoaldo
Posts: 26
Joined: Mon Apr 06, 2015 8:24 pm

Fit a multirow in a Table

Post by Diogo Remoaldo »

Hi I would like to know how to fit the whole text (Necessidades de Aquecimento e Necessidades de Arrefecimento) in the table.

Very much aprreciated for any help.

Code: Select all

\begin{tabular}{| m{1.5cm} | m{1.5cm} |c |c |c |c |c |c |c |c |c|} \hline
\multicolumn{2}{|c|}{Localização} & \multicolumn{3}{|c|}{Porto} & \multicolumn{3}{|c|}{Bragança} & \multicolumn{3}{|c|}{Faro}\\ \hline
\multicolumn{2}{|c|}{Orientação} & Sul & Poente & Norte & Sul & Poente & Norte & Sul & Poente & Norte\\ \hline
\multirow{2}{1.5cm}{ Necessidades de Aquecimento [$kWh/m^2.ano$]} & Espessura \newline 80 mm & Sul & Poente & Norte & Sul & Poente & Norte & Sul & Poente & Norte\\ \hhline{~----------}
 & Espessura \newline 100 mm & Sul & Poente & Norte & Sul & Poente & Norte & Sul & Poente & Norte\\ \hline
\multirow{2}{1.5cm}{Necessidades de Arrefecimento [$kWh/m^2.ano$]} & Espessura 80 mm & Sul & Poente & Norte &  Sul & Poente & Norte & Sul & Poente & Norte\\ \hhline{~----------}
 & Espessura 100 mm & Sul & Poente & Norte & Sul & Poente & Norte & Sul & Poente & Norte\\ \hline
\end{tabular}
diogoremoaldoTabulars.png
diogoremoaldoTabulars.png (55.96 KiB) Viewed 3848 times
Last edited by Johannes_B on Tue Apr 07, 2015 12:47 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

Diogo Remoaldo
Posts: 26
Joined: Mon Apr 06, 2015 8:24 pm

Re: Fit a multirow in a Table

Post by Diogo Remoaldo »

In other words I would like both the tables that can be seen in the attachment to match.

The first is the one I did in Latex (and it's incorrect because the text isn't correctly wrapped), the second I did it on word.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Fit a multirow in a Table

Post by Johannes_B »

Hi and welcome,

your table does not contain any information, or rather repeating information. I gues this is filler text, comparing with your word made table.

General rule of thumb is, avoid vertical lines in tabulars and use package booktabs. The manual of this package is very very good.

If you gie us the whole table, somebody will overhault the table to give it a more professional look.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Diogo Remoaldo
Posts: 26
Joined: Mon Apr 06, 2015 8:24 pm

Re: Fit a multirow in a Table

Post by Diogo Remoaldo »

Hi, the whole table is the one I did on the word (the second one). Yes there is lots of dummy text in the second table
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Fit a multirow in a Table

Post by Johannes_B »

Sorry, i wasn't clear enough. If you give us the whole table, in plain text, not a picture, we can do something. The truth is, we all do this in our spare time and nobody wants to type in mere text/numbers (yes, this can make a difference in the source).

Best even to post a compilable minimal example, that way we also see your margins, which migh lead to some extra trickery.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Diogo Remoaldo
Posts: 26
Joined: Mon Apr 06, 2015 8:24 pm

Fit a multirow in a Table

Post by Diogo Remoaldo »

Ok I am sorry :)

Here goes

Code: Select all

\begin{table}[htbp]
  \centering
  \caption{Add caption}
    \begin{tabular}{|C{1.5cm}|C{1.5cm}|c|c|c|c|c|c|c|c|c|}
    \toprule
    \multicolumn{2}{c}{Localidade} & \multicolumn{3}{c}{Bragança} & \multicolumn{3}{c}{Porto} & \multicolumn{3}{c}{Faro} \\
    \midrule
    \multicolumn{2}{c}{Orientação} & Sul   & Poente & Norte & Sul   & Poente & Norte & Sul   & Poente & Norte \\
    \multirow{2}[4]{*}{Necessidades de Aquecimento [$kWh/m^2.ano$]} & Espessura 80 mm & 28.51 & 28.40 & 28.75 & 10.96 & 11.60 & 28.75 & 4.91  & 5.83  & 4.96 \\
          & Espessura 100 mm & 22.05 & 22.04 & 22.34 & 8.14  & 8.30  & 22.34 & 2.86  & 2.89  & 22.34 \\
    \multirow{2}[4]{*}{Necessidades de Arrefecimento[$kWh/m^2.ano$]} & Espessura 80 mm & 6.29  & 9.54  & 7.36  & 4.98  & 7.96  & 5.74  & 10.41 & 14.42 & 12.39 \\
          & Espessura 100 mm & 6.20  & 9.37  & 7.17  & 5.11  & 9.37  & 7.17  & 10.39 & 15.78 & 12.41 \\
    \bottomrule
    \end{tabular}
  \label{tab:addlabel}
\end{table}
What I really need is to fit "Necessidades de Aquecimento [kWh/m^2.ano]" and"Necessidades de Arrefecimento [kWh/m^2.ano]" in the rows, in other words warp them.

I am really sorry for any possible disturbance and best regards!
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Fit a multirow in a Table

Post by Johannes_B »

This is quite tricky and i ended up filling in the values by hand again, so not all are included (and maybe some of them are just wrong).

I sat over an hour over this problem, and the table is pretty complicated, as there are many variables, the location, the orientation and the thickness. With the final value, this makes up a four dimensional system.

I don't what this is about, so i cannot say anything about the reading direction, or what has more effect on something, but you can see some ideas below. In my opinion, package siunitx can do a good job here to align the numerical values. Some stuff is fixed by hand, some isn't fixed at all. You can run the code by clicking on »Open in writelatex« (now overleaf) just above it.

One thing, that goes for tables as well. DRY (don't repeat yourself). That means, if you can, place some stuff in the caption.

Code: Select all

\documentclass[portuguese]{article}
\usepackage{multirow}
\usepackage{showframe}
\usepackage{booktabs}
\usepackage{babel}
\usepackage{array}
\usepackage{caption}
\usepackage{rotating}
\captionsetup[table]{position=above}
\usepackage{siunitx}
\sisetup{per-mode=symbol}
\DeclareSIUnit{\year}{ano}
\newcolumntype{C}{>{\centering\arraybackslash}p}
\begin{document}
\begin{tabular}{|C{2.5cm}|C{1.5cm}|c|c|c|c|c|c|c|c|c|}
	\toprule
	\multicolumn{2}{c}{Localidade} & \multicolumn{3}{c}{Bragança} & \multicolumn{3}{c}{Porto} & \multicolumn{3}{c}{Faro} \\
	\midrule
	\multicolumn{2}{c}{Orientação} & Sul   & Poente & Norte & Sul   & Poente & Norte & Sul   & Poente & Norte \\
	\multirow{2}[4]{2cm}{Necessidades de Aquecimento [$kWh/m^2.ano$]} & Espessura 80 mm & 28.51 & 28.40 & 28.75 & 10.96 & 11.60 & 28.75 & 4.91  & 5.83  & 4.96 \\
	& Espessura 100 mm & 22.05 & 22.04 & 22.34 & 8.14  & 8.30  & 22.34 & 2.86  & 2.89  & 22.34 \\
	\multirow{2}[4]{2cm}{Necessidades de Arrefecimento[$kWh/m^2.ano$]} & Espessura 80 mm & 6.29  & 9.54  & 7.36  & 4.98  & 7.96  & 5.74  & 10.41 & 14.42 & 12.39 \\
	& Espessura 100 mm & 6.20  & 9.37  & 7.17  & 5.11  & 9.37  & 7.17  & 10.39 & 15.78 & 12.41 \\
	\bottomrule
\end{tabular}
\clearpage
\begin{table}
	\caption{Table showing the stuff of three different
		locations, each in southern, western and northern
	direction}
\begin{tabular}{>{\hbox{}}p{2cm}p{1.5cm}ccccccccc}
	\toprule
	\multicolumn{2}{c}{Localidade} & \multicolumn{3}{c}{Bragança} & \multicolumn{3}{c}{Porto} & \multicolumn{3}{c}{Faro} \\
	\cmidrule(lr){3-5}
	\cmidrule(lr){6-8}
	\cmidrule(lr){9-11}
	\multicolumn{2}{c}{Orientação} & Sul   & Poente & Norte & Sul   & Poente & Norte & Sul   & Poente & Norte \\
	\cmidrule(lr){3-3}
	\cmidrule(lr){4-4}
	\cmidrule(lr){5-5}
	\cmidrule(lr){6-6}
	\cmidrule(lr){7-7}
	\cmidrule(lr){8-8}
	\cmidrule(lr){9-9}
	\cmidrule(lr){10-10}
	\cmidrule(lr){11-11}
	\multirow{3}{1.5cm}{Necessidades de Aquecimento [\si{kWh/m^2 ano}]} & Espessura \SI{80}{mm} & 28.51 & 28.40 & 28.75 & 10.96 & 11.60 & 28.75 & 4.91  & 5.83  & 4.96 \\
	& Espessura \SI{100}{mm} & 22.05 & 22.04 & 22.34 & 8.14  & 8.30  & 22.34 & 2.86  & 2.89  & 22.34 \\
	\multirow{3}{1.5cm}{Necessidades de Arrefecimento [\si{kWh/m^2
	ano}]} & Espessura
\SI{80}{mm} & 6.29  & 9.54  & 7.36  & 4.98  & 7.96  & 5.74  & 10.41 & 14.42 & 12.39 \\
& Espessura \SI{100}{mm} & 6.20  & 9.37  & 7.17  & 5.11  & 9.37  & 7.17  & 10.39 & 15.78 & 12.41 \\
	\bottomrule
\end{tabular}
\bigskip
\centering
	\caption{Table showing the necessity of stuff (in \si{\kWh\per\meter\squared\per\year}) of three different
		locations, each in southern, western and northern
	direction}
\begin{tabular}{llSSSS}
	\toprule
	            &             & \multicolumn{2}{c}{Necessidades de} & \multicolumn{2}{c}{Necessidades de} \\
	 Localidade & Orientation & \multicolumn{2}{c}{Aquecimento}     & \multicolumn{2}{c}{Arrefecimento}  \\
	\cmidrule(lr){3-4}
	\cmidrule(lr){5-6}
	                      &                     & \SI{80}{mm} & \SI{100}{mm} & \SI{80}{mm} & \SI{100}{mm} \\
			      \cmidrule(lr){3-3}
			      \cmidrule(lr){4-4}
			      \cmidrule(lr){5-5}
			      \cmidrule(lr){6-6}
                        & Sul                 & 17.65       & 12.29        & 12.54       & 12.79\\
	Bragan\c{c}a          & Poente              & 18.33       & 12.95        & 13.49       & 13.88\\
	                      & Norte               & 17.94       & 12.6         & 14.24       & 14.51\\\addlinespace
	                      & Sul                 & 5.39        & 3.05         & 12.03       & 12.93\\
	Porto                 & Poente              & 5.8         & 3.4          & 12.91       & 13.84\\
	                      & Norte \\\addlinespace
	                      & Sul \\
	Fago                  & Poente \\
	                      & Norte \\
			   \bottomrule
\end{tabular}
\end{table}

\begin{sidewaystable}
	\caption{Table showing the necessity of stuff (in \si{\kWh\per\meter\squared\per\year}) of three different
		locations, each in southern, western and northern
	direction}
\begin{tabular}{>{\hbox{}}p{4cm}p{1.5cm}ccccccccc}
	\toprule
	\multicolumn{2}{c}{Localidade} & \multicolumn{3}{c}{Bragança} & \multicolumn{3}{c}{Porto} & \multicolumn{3}{c}{Faro} \\
	\cmidrule(lr){3-5}
	\cmidrule(lr){6-8}
	\cmidrule(lr){9-11}
	\multicolumn{2}{c}{Orientação} & Sul   & Poente & Norte & Sul   & Poente & Norte & Sul   & Poente & Norte \\
	\cmidrule(lr){3-3}
	\cmidrule(lr){4-4}
	\cmidrule(lr){5-5}
	\cmidrule(lr){6-6}
	\cmidrule(lr){7-7}
	\cmidrule(lr){8-8}
	\cmidrule(lr){9-9}
	\cmidrule(lr){10-10}
	\cmidrule(lr){11-11}
	\multirow{3}{3.5cm}{Necessidades de Aquecimento } & Espessura \SI{80}{mm} & 28.51 & 28.40 & 28.75 & 10.96 & 11.60 & 28.75 & 4.91  & 5.83  & 4.96 \\
	& Espessura \SI{100}{mm} & 22.05 & 22.04 & 22.34 & 8.14  & 8.30  & 22.34 & 2.86  & 2.89  & 22.34 \\\addlinespace
	\multirow{1}{3.5cm}{Necessidades de Arrefecimento } & Espessura \SI{80}{mm} & 6.29  & 9.54  & 7.36  & 4.98  & 7.96  & 5.74  & 10.41 & 14.42 & 12.39 \\
& Espessura \SI{100}{mm} & 6.20  & 9.37  & 7.17  & 5.11  & 9.37  & 7.17  & 10.39 & 15.78 & 12.41 \\
	\bottomrule
\end{tabular}
\end{sidewaystable}
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply