3

I'm trying to learn the TeX language in preparation for my final engineering project before I graduate, and while I've been able to find most of the solutions online, I can't seem to find a solution for this one. I'm trying to format a table so that the Large text is centered vertically and horizontally and that the table itself is centered on the page. The Large text, in the format I have it in now, is touching the top of the hline.

Table as it stands now

Here's the code:

\documentclass[11pt]{article}
\usepackage{array}
\begin{document}

%\begin{center}


\begin{table}[ht]

\caption{Room 6 - Customer Assessments of Competing Products}
\begin{tabular}{|c|c|c|}\hline
\Large
Customer Requirements  & \Large Zhang Company & \Large Wisking Company \\[2ex] \hline 

Standard size & 3 &1\\ \hline
Pushed Manually & 5&3 \\ \hline
Max Weight = 150 & 2& 3 \\ \hline
Lifespan &3&4\\ \hline
Rigid Backrest &3&3\\ \hline
Adjustable&2&2\\ \hline
Easy Operation&1&3\\ \hline
Left-/Right-hand Steering&3&4\\ \hline
Drive Up Inclines&4&4\\ \hline
Non-Obtrusive Motor&4&3\\ \hline
Non-Obtrusive Electrical Components&3&5\\ \hline
Safety&3&5\\ \hline
Braking&5&5\\ \hline
\multicolumn{3}{c}{1 - Poor; 3 - Good; 5 - Excellent}


\end{tabular}
\end{table}
%\end{center}
\end{document}

Much appreciated. Hopefully I've been descriptive enough.

1

3 Answers 3

5

enter image description here

Made the table narrower so it could be centred, and added vertical space here and there.

(You could consider having less rules in the table...)

\documentclass[11pt]{article}
\usepackage{array}
\begin{document}




\begin{table}[ht]
\setlength\extrarowheight{2pt}
\centering
\caption{Room 6 - Customer Assessments of Competing Products}
\medskip
\begin{tabular}{|c|c|c|}\hline
\Large
\rule{0pt}{1.5em}%
Customer  & \Large Zhang & \Large  Company \\
\Large Requirements  & \Large  Company & \Large Company \\[2ex] \hline 

Standard size & 3 &1\\ \hline
Pushed Manually & 5&3 \\ \hline
Max Weight = 150 & 2& 3 \\ \hline
Lifespan &3&4\\ \hline
Rigid Backrest &3&3\\ \hline
Adjustable&2&2\\ \hline
Easy Operation&1&3\\ \hline
Left-/Right-hand Steering&3&4\\ \hline
Drive Up Inclines&4&4\\ \hline
Non-Obtrusive Motor&4&3\\ \hline
Non-Obtrusive Electrical Components&3&5\\ \hline
Safety&3&5\\ \hline
Braking&5&5\\ \hline
\multicolumn{3}{c}{\rule{0pt}{1.5em}%
1 - Poor; 3 - Good; 5 - Excellent}


\end{tabular}
\end{table}

\noindent X\dotfill X

\noindent X\dotfill X


\end{document}
2

To place a table on a page by itself, vertically centered, use the [p] location specifier when initiating the table environment.

If you're willing to change the relative font size of the header row from \Large to \large, you can (i) make the table fit into the text block and (ii) help avoid the "ransom note look" that may arise all to easily when using different font sizes for items that are visually close. To get better vertical spacing between the \hline rules and the text below them, insert "struts" (objects of some height but without width, hence invisible) that jut up above the line of text. I would also recommend getting rid of most horizontal lines and all vertical lines in the table -- all they really add is visual clutter.

enter image description here

\documentclass[11pt]{article}
\newcommand{\Tstrut}{\rule{0pt}{2.5ex}} % "top strut"
\begin{document}
\begin{table}[p] % use 'p' specifier to place float on a page by itself
\centering
\caption{Room 6 --- Customer Assessments of Competing Products} 

\medskip % add some separation between caption and table
\begin{tabular}{@{}lcc@{}}
\hline 
\large Customer Requirements \rule{0pt}{3.5ex} & 
\large Zhang Company &
\large Wisking Company \\[1ex] 
\hline
Standard size & 3 &1\Tstrut\\ 
Pushed Manually & 5&3 \\ 
Max Weight = 150 & 2& 3 \\ 
Lifespan &3&4\\ 
Rigid Backrest &3&3\\ 
Adjustable&2&2\\ 
Easy Operation&1&3\\ 
Left-/Right-hand Steering&3&4\\ 
Drive Up Inclines&4&4\\ 
Non-Obtrusive Motor&4&3\\ 
Non-Obtrusive Electrical Components&3&5\\ 
Safety&3&5\\ 
Braking&5&5\\ 
\hline
& \multicolumn{2}{l@{}}{1 - Poor; 3 - Good; 5 - Excellent\Tstrut}\\
\cline{2-3}
\end{tabular}
\end{table}
\end{document}
1

Your first problem was that the table was larger than \textwidth. I've set the page about as large as it can get. The \rules are just to help show where the page limits are.

I avoid table and figure. They never go where I want them to be. Lastly, I fudged the \raisebox until it looked good. I don't know if it is precisely centered or not.

\documentclass[11pt]{article}
\usepackage{array}

\setlength{\topmargin}{0pt}
\setlength{\headheight}{0pt}
\setlength{\headsep}{0pt}
\setlength{\footskip}{0in}
\setlength{\textheight}{9.5in}

\setlength{\oddsidemargin}{0pt}
\setlength{\evensidemargin}{0pt}
\setlength{\marginparwidth}{0pt}
\setlength{\marginparsep}{0pt}
\setlength{\textwidth}{6.5in}
\pagestyle{empty}

\newcommand{\mybox}[1]{\raisebox{-.05in}[0.2in][0.2in]{#1}}

\begin{document}

\noindent\rule{\textwidth}{1pt}\\
\vfill
\begin{center}
\begin{tabular}{|c|c|c|}
\multicolumn{3}{l}{Room 6 - Customer Assessments of Competing Products}\\
\hline
\mybox{\Large Customer Requirements}  & \mybox{\Large Zhang Company}
 & \mybox{\Large Wisking Company} \\
\hline 
Standard size & 3 &1\\ \hline
Pushed Manually & 5&3 \\ \hline
Max Weight = 150 & 2& 3 \\ \hline
Lifespan &3&4\\ \hline
Rigid Backrest &3&3\\ \hline
Adjustable&2&2\\ \hline
Easy Operation&1&3\\ \hline
Left-/Right-hand Steering&3&4\\ \hline
Drive Up Inclines&4&4\\ \hline
Non-Obtrusive Motor&4&3\\ \hline
Non-Obtrusive Electrical Components&3&5\\ \hline
Safety&3&5\\ \hline
Braking&5&5\\ \hline
\multicolumn{3}{c}{1 - Poor; 3 - Good; 5 - Excellent}
\end{tabular}
\end{center}
\vfill
\noindent\rule{\textwidth}{1pt}\\
\end{document}
4
  • If someone wants to edit the \raisebox, be my guest. Aug 22, 2013 at 23:22
  • 1
    avoiding figure/table floats isn't really feasible in larger documents unless you are prepared to manually move every table in the source to achieve reasonable page breaks. Aug 22, 2013 at 23:29
  • Which is precisely what I do. I'll use them if I want it to go the the top of the next page or create a page of floats, but never [h]. I can make my own captions. Aug 23, 2013 at 15:44
  • yes well [h] means "please take to end of document" so not using that is advisable. [htp] is a bit more reasonable, but yes if you want h you probably want to make the surrounding text match the fact that it is there, so probably don't want it to float, ever. Aug 23, 2013 at 15:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .