1

I have created a table, and I have fixed its width, but the problem is that when I rotate the text of the cell by using \rotatebox, the text did not place in the center of the cell. who can I change its place ? My table:

\documentclass{article}
\usepackage[utf8]{inputenc}


\usepackage{natbib}
\usepackage{graphicx}
\usepackage{amsmath}

\begin{document}









\begin{center}
\begin{table*}[htp]
%\scriptsize        
\centering
%\begin{tabular}{|l|l|l|l|l|l|l|l|l|}


\begin{tabular} {|p{0.04\textwidth}|p{0.04\textwidth}|p{0.12\textwidth}|p{0.12\textwidth}|p{0.12\textwidth}|p{0.12\textwidth}|p{0.12\textwidth}|p{0.12\textwidth}|p{0.02\textwidth}|} 
\hline


Text text text text
&

Text text text text
&

Text text text text
& 

Text text text text
& 

Text text text text
\\ \hline

{\multirow [c]{2}{*}{\rotatebox{90}{ {Example 1} }}}  & 
%[origin=c]
{\multirow [c]{3}{*}{\rotatebox{90}{ Example 2 }}}


 & 

Text text text text
& 
Text text text text
& 

%\begin{tabular} {@{}l@{}}
%\begin{tabular}[c]{@{}l@{}}
 
Text text text text

Text text text text
%\end{tabular}


 & 
 
 

%\begin{tabular}{@{}l@{}}

Text text text text
Text text text text
Text text text text

%\end{tabular}  

  & 
Text text text text
Text text text text
Text text text text
Text text text text
& 
Text text text text

& r1 \\ \cline{3-9}&  & 

Text text text text
& 
Text text text text
& 
 
 
 
 %\begin{tabular}{@{}l@{}}


Text text text text
Text text text text
%\end{tabular}

& 

Text text text text
&

Text text text text& 

Text text text text
& 

r2 \\ 


\cline{1-1} \cline{3-9} 

{\rotatebox[origin=c]{90}{ Feedback }}  &  
&
Text text text text

 &
Text text text text
& 
Text text text text

& 
Text text text text

& Text text text text

& 
%\multicolumn{1}{c|}{
//
%} 
& 

r3 

\\ 
\hline

{\rotatebox[origin=c]{90}{   Example 3    }} & 

{\rotatebox[origin=c]{90}{ Example 4 }} 
& 
Text text text text
&
Text text text text
& 
%\begin{tabular} {@{}l@{}}
Text text text text
 Cost. 
%\end{tabular}
&
Text text text text
& 
Text text text text
& 
Text text text text

& 


r4 

\\ \hline

\end{tabular}

\end{table*}
\end{center}
\end{document}

I wan't to change the replace of the word example1 and example2 it in the center of the cell.enter image description here

2

Like this?

enter image description here

In \multirow command you need to set number of text lines in rows, which are spanned by it. For example, "Example 1" spans 12 text lines, so instead of

{\multirow [c]{2}{*}{\rotatebox{90}{ {Example 1} }}}

you should write

\multirow{12}{*}{\rotatebox{90}{Example 1}}

That table is fit inside \textwidth I suggest to use tabularx table environment. Complete MWE is:

\documentclass{article}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{ragged2e}
\usepackage{multirow, tabularx}


\begin{document}
    \begin{table}[htp]
\small
\centering
\begin{tabularx} {\linewidth} {|p{0.04\textwidth}|p{0.04\textwidth}|*{6}{>{\RaggedRight}X|}l|}
    \hline
Text text text text
& Text text text text
& Text text text text
& Text text text text
& Text text text text
&&&&    \\ \hline
\multirow{12}{*}{\rotatebox{90}{Example 1}}
& \multirow{16}{*}{\rotatebox{90}{Example 2}}
& Text text text text
& Text text text text
& Text text text text Text text text text
& Text text text text Text text text text Text text text text
& Text text text text Text text text text Text text text text Text text text text
& Text text text text
& r1 \\ \cline{3-9}
&  & Text text text text
& Text text text text
& Text text text text Text text text text
& Text text text text
& Text text text text
& Text text text text
& r2 \\ \cline{1-1} \cline{3-9}
\multirow{4.4}{*}{\rotatebox{90}{Feedback}}
&   &   &   &   &   &   &   &       \\
&   & Text text text text
& Text text text text
& Text text text text
& Text text text text
& Text text text text
&   & r3    \\
&   &   &   &   &   &   &   &       \\
    \hline
\multirow{5}{*}{\rotatebox{90}{Example 3}}
& \multirow{5}{*}{\rotatebox{90}{Example 4}}
&   &   &   &   &   &   &         \\
&
& Text text text text
& Text text text text
& Text text text text Cost.
& Text text text text
& Text text text text
& Text text text text
& r4    \\
&   &   &   &   &   &   &   &       \\
    \hline
\end{tabularx}
    \end{table}
\end{document}
7
  • I changed it but still the same problem – stevGates Jun 14 '20 at 0:22
  • @Zarko I don't know who would down vote this answer and for what reason? I worry the author of the question did that by mistake. – hesham Jun 14 '20 at 3:43
  • @Brm-Covißio If you think this answer is not helpful, you may not accept it and leave it as it is, with neither up or down voting it, at least for the effort it took to be posted. – hesham Jun 14 '20 at 3:46
  • @Brm-Covißio, what you changed? Where you changed? My MWE as it is, works as shown on picture in my answer. – Zarko Jun 14 '20 at 8:12
  • Thank you very much @Zarko. – stevGates Jun 14 '20 at 10:56
2

With the environment {NiceTabular} of nicematrix (≥ 4.1), you have a command \Block which centers its content mathematically in the merged cells (you don't have to count the text lines). Moreover, you have a keyword \rotate to rotate the content of the block.

You have also a key hvlines which draws all the rules excepted in the blocks (so, you don't have to use \cline).

\documentclass{article}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{nicematrix}


\begin{document}
\begin{table}[htp]
\small
\centering
\NiceMatrixOptions{cell-space-top-limit=2pt,cell-space-bottom-limit=2pt}
\newcolumntype{P}[1]{>{\raggedright}p{#1\textwidth}}
\begin{NiceTabular}{P{0.04}P{0.04}P{0.12}P{0.12}P{0.12}P{0.12}P{0.12}P{0.12}C}[hvlines]
Text text text text
& Text text text text
& Text text text text
& Text text text text
& Text text text text
& & & & \\
\Block{2-1}{\rotate Example 1}
& \Block{3-1}{\rotate Example 2}
& Text text text text
& Text text text text
& Text text text text Text text text text
& Text text text text Text text text text Text text text text
& Text text text text Text text text text Text text text text Text text text text
& Text text text text
& r1 \\ 
&  
& Text text text text
& Text text text text
& Text text text text Text text text text
& Text text text text
& Text text text text
& Text text text text
& r2 \\ 
\multicolumn{1}{C}{\rotatebox[origin=b]{90}{Feedback\vphantom{p}}}
&   & Text text text text
& Text text text text
& Text text text text
& Text text text text
& Text text text text
&   & r3    \\
\multicolumn{1}{C}{\rotatebox[origin=b]{90}{Example 3}}
& \multicolumn{1}{C}{\rotatebox[origin=b]{90}{Example 4}}
& Text text text text
& Text text text text
& Text text text text Cost.
& Text text text text
& Text text text text
& Text text text text
& r4    \\
\end{NiceTabular}
\end{table}
\end{document}

Output of the above code

1
  • 1
    @Schrödinger's cat: As for now, they are many drawbacks in nicematrix. The environments of nicematrix can't be nested. There is no X column as in tabularx and the environments can't be cut by a page break as in longtable... Maybe in future versions... (P.S. : I will translate the title). Thanks. – F. Pantigny Jun 15 '20 at 6:06

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.