1

I am trying to move first cell text "Assembly" to the center of cell. I already tried raisebox, parbox and many more things but nothing worked. Please help me. And, I don't want to change the rotation of other cells.

    \newcommand*\rot{\rotatebox{90}}
    \begin{table}[h!]
    \renewcommand{\arraystretch}{1.4}
    \begin{tabular}{|c|c|c|c|c|c|c|c|c|c|}
    \hline
    Assembly & \rot{Contigs} & \rot{Largest contig} & \rot{Total length} & 
    \rot{Misassemblies} & \rot{Local misassemblies} & \rot{Mismatches per 100KB} &
    \rot{N50} & \rot{Predicted genes} & \rot{Genome fraction (\%)}\\
    \hline
    \end{tabular}
    \end{table}

current latex output

2 Answers 2

1

Using a multirow with a height correction works. I removed the \arraystretch=1.4 as it didn't do anything here (maybe you need it for your real table) and used \multirowcell from the makecell package, as the syntax is slightly simpler, and the package has commands to add vertical padding to cells (\gape'…}).

\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{makecell}
\newcommand*\rot[1]{\rotatebox{90}{#1}}

\begin{document}

    \begin{table}[h!]
    \begin{tabular}{|c|c|c|c|c|c|c|c|c|c|}
    \hline
    \multirowcell{1}[11ex]{Assembly}& \rot{Contigs} & \rot{Largest contig} & \rot{Total length} &
    \rot{Misassemblies} & \rot{Local misassemblies} &\gape[t]{\rot{Mismatches per 100KB}} &
    \rot{N50} & \rot{Predicted genes} & \rot{Genome fraction (\%)}\\
    \hline
    \end{tabular}
    \end{table}

\end{document}

enter image description here

4
  • Rather than \newcommand*\rot{\rotatebox{90}}, I'd write \newcommand*\rot[1]{\rotatebox{90}{#1}}.
    – Mico
    Mar 29, 2016 at 9:57
  • @Mico: I reused the O.P.'s code for this one, but it works. Is there any drawback?
    – Bernard
    Mar 29, 2016 at 10:00
  • The OP's code for the \rot macro just happens to work as (a) the underlying \rotatebox macro expects two arguments and (b) \rot is being followed by a braces-delimited expression in all instances. The main advantage, in my view, of specifying explicitly that \rot takes exactly one argument is that it simplifies debugging, should a user ever forget to provide an argument for \rot.
    – Mico
    Mar 29, 2016 at 10:17
  • I see. 'Tis corrected. Thanks for the information!
    – Bernard
    Mar 29, 2016 at 10:36
2

Instead of \rotatebox{90} you can use \rotatebox[origin=c]{90} to rotate boxes around their centers

\documentclass[12pt]{article}
\usepackage{graphicx}


\begin{document}

\newcommand*\rot{\rotatebox[origin=c]{90}}
    \begin{table}[h!]
    \renewcommand{\arraystretch}{1.4}
    \begin{tabular}{|c|c|c|c|c|c|c|c|c|c|}
    \hline
    Assembly & \rot{Contigs} & \rot{Largest contig} & \rot{Total length} & 
    \rot{Misassemblies} & \rot{Local misassemblies} & \rot{Mismatches per 100KB} &
    \rot{N50} & \rot{Predicted genes} & \rot{Genome fraction (\%)}\\
    \hline
    \end{tabular}
    \end{table}


\end{document}

enter image description here

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.