Graphics, Figures & TablesTable Formatting

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
p2ya
Posts: 3
Joined: Tue Jan 17, 2012 12:53 am

Table Formatting

Post by p2ya »

Hi,
I have recently had issues with vertical lines and wrapping text in table. I really appreciate if you have a look at my code and guide me to fix it.

Code: Select all

\begin{table}

\begin{tabular}{ |p{3cm} | p{3cm} | p{3cm} | p{4cm} | } \hline

\multicolumn{4}{|c|}
{ \begin{large} {\textbf{Summary Allocation of Primary Energy Consumption U.S. Manufacturing Sector in 2001}}
\end{large}} \\ \hline \hline

\textbf{Stage of manufacturing energy use} &\textbf{Volume of energy (trillion Btu)} &\textbf{Percent of original energy input available at this stage}  & \textbf{Characterization of losses}\\ [1ex] \hline 

 Primary energy input & 24,658 & \multirow{2} {*} {100\%}& \multirow{2} {*} {Energy is lost by power utilities in the generation of electricity. Also, electricity and fuel is lost in transit to industrial facilities.}\\  \cline{1-2}
Off-site losses	& -6,884\\ \hline

Central energy plant	& 17,774 & \multirow{3} {*} {72\%}& \multirow{3} {*} {Powerhouse combustion efficiency determines the proportion of fuel that is converted to heat and power.} \\ \cline{1-2}
Steam generation loss	& -1,233 \\ \cline{1-2}
Power loss	& -166 \\ \hline

Energy distribution	& 	16,375 & \multirow{4} {*} {66\%}& \multirow{4} {*} {Distribution pipes and vessels sustain a variety of leaks and radiation losses.} \\ \cline{1-2}
Distribution loss	& 	-1,330 \\ \cline{1-2}
Energy exported offsite	& 	-79 \\ \cline{1-2} 
Energy for facility heating and cooling 	& -1,405\\ \hline

Energy conversion	& 	13,561 & \multirow{2} {*} {55\%}& \multirow{2} {*} {A combination of inefficiencies, some avoidable and some not, are encountered as energy is converted to motive energy used by motor drives, pumps, heat exchangers, etc.} \\ \cline{1-2}
Energy conversion inefficiencies	& 	-2,862 \\ \hline

Energy applied as process work& 	10,699 &	43\%	& An indeterminate volume of residual energy after process work is either reapplied to central generation or is lost without reclamation. \\ \hline


\end{tabular}

\end{table} 


As you can see there are incomplete vertical lines in multi rows and also last column has unwrapped text which I would like all the text being centred and aligned to the table.

Cheers,
Pouya
Last edited by Stefan Kottwitz on Sat Feb 04, 2012 11:25 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.

User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Table Formatting

Post by Stefan Kottwitz »

Hi,

if you would have posted a compilable Infominimal working example, I guess somebody would have tested it and would have showed you how to fix this. Perhaps that's the reason why you did not get an answer. The problems are easy to fix:
  • To get the missing vertical lines, add some & in the corresponding columns, to define cells.
  • For wrapping, add a width argument to \multirow instead of *, such as \multirow{4}{9cm}{text}.
A working example:

Code: Select all

\documentclass{article}
\usepackage{multirow}
\usepackage{pdflscape}
\begin{document}
\begin{landscape}
\begin{table}
\begin{tabular}{ |p{3cm} | p{3cm} | p{3cm} | p{9cm} | } \hline
\multicolumn{4}{|c|}
{ \begin{large} {\textbf{Summary Allocation of Primary Energy Consumption U.S. Manufacturing Sector in 2001}}
\end{large}} \\ \hline \hline
\textbf{Stage of manufacturing energy use} &\textbf{Volume of energy (trillion Btu)} &\textbf{Percent of original energy input available at this stage}  & \textbf{Characterization of losses}\\ [1ex] \hline
 Primary energy input & 24,658 & \multirow{2} {*} {100\%}& \multirow{2} {9cm} {Energy is lost by power utilities in the generation of electricity. Also, electricity and fuel is lost in transit to industrial facilities.}\\  \cline{1-2}
Off-site losses & -6,884 & & \\ \hline
Central energy plant    & 17,774 & \multirow{3} {*} {72\%}& \multirow{3} {9cm} {Powerhouse combustion efficiency determines the proportion of fuel that is converted to heat and power.} \\ \cline{1-2}
Steam generation loss   & -1,233 & & \\ \cline{1-2}
Power loss      & -166 & & \\ \hline
Energy distribution     &       16,375 & \multirow{4} {*} {66\%}& \multirow{4} {9cm} {Distribution pipes and vessels sustain a variety of leaks and radiation losses.} \\ \cline{1-2}
Distribution loss       &       -1,330 & & \\ \cline{1-2}
Energy exported offsite &       -79 & & \\ \cline{1-2}
Energy for facility heating and cooling         & -1,405 & & \\ \hline
Energy conversion       &       13,561 & \multirow{2} {*} {55\%}& \multirow{2} {9cm} {A combination of inefficiencies, some avoidable and some not, are encountered as energy is converted to motive energy used by motor drives, pumps, heat exchangers, etc.} \\ \cline{1-2}
Energy conversion inefficiencies        &       -2,862 & & \\ \hline
Energy applied as process work&         10,699 &        43\%    & An indeterminate volume of residual energy after process work is either reapplied to central generation or is lost without reclamation. \\ \hline
\end{tabular}
\end{table}
\end{landscape}
\end{document}
table.png
table.png (17.59 KiB) Viewed 1801 times
I would not use vertical lines, which interrupt reading through the rows. If at all, I would use some horizontal lines for designing tables.

Stefan
LaTeX.org admin
Post Reply