1

When I try to make a table I get a well spaced table but my text is only centered horizontally. Is there a way to center the text in the table vertically as well?

\begin{table*}[]
\renewcommand\arraystretch{1.5}
\centering
\caption{Table}
\label{my-label}
\resizebox{\textwidth}{!}{%
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
\textbf{c} & \textbf{c} & \textbf{c} & \textbf{c} & \textbf{c} & \textbf{c} & \textbf{c} \\ \hline
\textbf{c} & c & c & c & c & c & c \\ \hline
\end{tabular}
}
\end{table*}
  • 1
    Welcome to TeX.SE. Start by deleting all [10pt] spacing modifiers. If you wish to create a less cramped "look", insert an instruction such as \renewcommand\arraystretch{1.5} after \begin{table}. – Mico Dec 11 '16 at 21:10
  • Welcome to TeX.SX! Please extend the snippet to a full minimal working example (MWE). – Heiko Oberdiek Dec 11 '16 at 21:10
  • The cells in the revised, now much simpler, tabular environment are centered vertically. – Mico Dec 11 '16 at 21:29
  • Welcome! You should avoid using \resizebox for tables. – Bernard Dec 11 '16 at 21:30
2

I got what you wanted by removing the wrapper you used \resizebox{\textwidth}{!}{% } and leaving all the code you had inside that.

\documentclass{article}
\begin{document}
\begin{table*}[]
\renewcommand\arraystretch{1.5}
\centering
\caption{Table}
\label{my-label}
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
\textbf{c} & \textbf{c} & \textbf{c} & \textbf{c} & \textbf{c} & \textbf{c} & \textbf{c} \\ \hline
\textbf{c} & long word & arsodunarsodu & a sentence is here.& c & c & c \\ \hline
\end{tabular}
\end{table*}

\end{document}

related question:vertically align text in table in LaTeX enter image description here

| improve this answer | |
  • This reads more like a comment than an answer. – Mico Dec 11 '16 at 21:31
1

Your question is not very clear ... I assume, that you looking for something like this:

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}%
\usepackage[showframe]{geometry}
\usepackage{caption}
\usepackage{tabularx}
    \renewcommand\tabularxcolumn[1]{m{#1}}
    \newcolumntype{C}{>{\centering\arraybackslash}X}

\begin{document}

    \begin{table}
\renewcommand\arraystretch{1.5}
    \centering
    \caption{caption}
    \label{my-label}
\begin{tabularx}{\textwidth}{|*{7}{C|}}
\hline
\textbf{c} & \textbf{c} & \textbf{c} & \textbf{c} & \textbf{c} & \textbf{c} & \textbf{c} \\ \hline
\textbf{c} & c & c & c & c & c & c \\ \hline
\end{tabularx}
    \end{table}

\end{document} 

As you can see, I don't use \resizebox{\textwidth}{!}{ ... }, which also change (enlarge/shrink) font size in table. Instead it I suggest to use tabularx and redefine its column type (see MWE).

| improve this answer | |
1

(This answer is based on the OP's original code.)

You should get rid of all [10pt] vertical spacing adjusters. In addition, you should contemplate (a) increasing the value of \arraystretch, (b) getting rid of all vertical lines and most horizontal lines and (c) introducing linebreaks in the header cells, as the cells are needlessly wide otherwise. That way, the need to reduce the table size (via \resizebox) becomes much less extreme than it is in your original code.

By getting rid of most horizontal lines, the issue of how to achieve vertical centering between the lines simply disappears, i.e., it is simply no longer relevant. :-)

I would also (d) get rid of most boldface which, when overused (as I would say is the case here), achieves nothing at all.

enter image description here

\documentclass{article}
\usepackage{graphicx,booktabs}
\usepackage[table]{xcolor}
\newcommand\mycolor{\cellcolor[HTML]{FFCC67}}
\usepackage[skip=0.33\baselineskip]{caption}
\newcommand\mycell[1]{%
   \begin{tabular}[t]{@{}c@{}} #1 \end{tabular}}
\begin{document}

\begin{table}
\captionsetup{font=scriptsize}
\caption{Selection Matrix}
\label{my-label}
\resizebox{\textwidth}{!}{%
\scriptsize%
\renewcommand\arraystretch{1.3}%
\setlength\arraycolsep{2pt}%
\begin{tabular}{@{}lr*{5}{c}@{}}
\toprule
Criteria & Weight & \mycell{Skin-\\Gun\textsuperscript{TM}} & \mycell{Auto-\\graft} & \mycell{Strata-\\graft\textsuperscript{\textregistered}} & \mycell{Amniotic\\Membrane} & \mycell{Silver Nitrate\\Solution} \\ 
\midrule
Safety             & 20\% & 5 & \mycolor\textbf{3} & 4 & 2 & 2 \\ 
Effectiveness      & 20\% & 4 & \mycolor\textbf{3} & 4 & 3 & 2 \\ 
Healing Time       & 15\% & 4 & \mycolor\textbf{3} & 4 & 4 & 2 \\ 
Invasiveness       & 10\% & 5 & 1 & \mycolor\textbf{3} & 5 & 4 \\ 
Easy to Apply      & 10\% & 4 & 1 & 2 & 5 & \mycolor\textbf{3} \\ 
Preparation        &7.5\% & 3 & 1 & \mycolor\textbf{3} & 3 & 5 \\ 
Availability       &  5\% & 1 & \mycolor\textbf{3} & 1 & 2 & 5 \\
Post-Treatment Aesthetics & 5\% & 5 & 1 & \mycolor\textbf{3} & 2 & 2 \\
Affordability      &  5\% & 1 & \mycolor\textbf{3} & 3 & 4 & 5 \\
Hospital Stay Time &2.5\% & 1 & \mycolor\textbf{3} & 3 & 4 & 5 \\ \midrule
Score & & 3.975 & 2.35 & 3.375 & 3.325 & 2.9 \\ 
Rank  & & 1 & 5 & 2 & 3 & 4 \\ \bottomrule
\end{tabular}
}
\end{table}
\end{document}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.