如何对齐旋转的表格文本?

如何对齐旋转的表格文本?

我把表格的标题旋转了90度。

不幸的是,标题与表格内容不匹配。截图:

在此处输入图片描述

这可以改变吗?我已经试过了,parbox但没有用。

这是我的表格:

\begin{tabular}{cccc}       

    \noalign{\vskip\doublerulesep}

    & CSS & Canvas & SVG

    \tabularnewline[\doublerulesep]

    \multirow{1}{*}{\rotatebox{90}{\mbox{Google Chrome}}} 
    & \includegraphics[scale=0.7]{images/screenshots/chrome_css3}
    & \includegraphics[scale=0.7]{images/screenshots/chrome_canvas}
    & \includegraphics[scale=0.7]{images/screenshots/chrome_svg}    

    \tabularnewline[\doublerulesep]

    \multirow{1}{*}{\rotatebox{90}{\mbox{Opera}}} 
    & \includegraphics[scale=0.7]{images/screenshots/opera_css3}    
    & \includegraphics[scale=0.7]{images/screenshots/opera_canvas}
    & \includegraphics[scale=0.7]{images/screenshots/opera_svg} 

    \tabularnewline[\doublerulesep]

    \multirow{1}{*}{\rotatebox{90}{\mbox{Mozilla Firefox}}} 
    & \includegraphics[scale=0.7]{images/screenshots/firefox_css3}  
    & \includegraphics[scale=0.7]{images/screenshots/firefox_canvas}
    & \includegraphics[scale=0.7]{images/screenshots/firefox_svg}   

    \tabularnewline[\doublerulesep]

    \multirow{1}{*}{\rotatebox{90}{\mbox{Apple Safari}}} 
    & \includegraphics[scale=0.7]{images/screenshots/safari_css3}   
    & \includegraphics[scale=0.7]{images/screenshots/safari_canvas}
    & \includegraphics[scale=0.7]{images/screenshots/safari_svg}    

\end{tabular}

Stack Exchange 上的相关帖子对我没有帮助。

我用multirow错了吗?

答案1

这与@HarishKumar 的方法类似。但为了让标题在行上居中,我设置了图像的高度。

不过,在这里,我设置了图像heightgraphicx包将适当缩放宽度。这样您就可以标记行并手动居中它们,就像我通过将内容括在两个之间所做的那样\hspace*{\fill}

\documentclass{article}
\usepackage{graphicx}
\usepackage[margin=1in]{geometry}
\begin{document}
  \renewcommand{\arraystretch}{1.2}
  \begin{tabular}{cccc}

    \noalign{\vskip\doublerulesep}

    & CSS & Canvas & SVG

    \tabularnewline[4ex]

    \rotatebox{90}{\parbox[t]{1.25in}{\hspace*{\fill}Google Chrome\hspace*{\fill}}}
    & \fbox{\rotatebox[origin=c]{-45}{\includegraphics[totalheight=1.25in]{example-image-10x16}}}
    & \fbox{\rotatebox[origin=c]{-45}{\includegraphics[totalheight=1.25in]{example-image-10x16}}}
    & \fbox{\rotatebox[origin=c]{-45}{\includegraphics[totalheight=1.25in]{example-image-10x16}}}

    \tabularnewline[4ex]

     \rotatebox{90}{\parbox[t]{1.25in}{\hspace*{\fill}Opera\hspace*{\fill}}}
    & \fbox{\rotatebox[origin=c]{-45}{\includegraphics[totalheight=1.25in]{example-image-10x16}}}
    & \fbox{\rotatebox[origin=c]{-45}{\includegraphics[totalheight=1.25in]{example-image-10x16}}}
    & \fbox{\rotatebox[origin=c]{-45}{\includegraphics[totalheight=1.25in]{example-image-10x16}}}

    \tabularnewline[4ex]

     \rotatebox{90}{\parbox[t]{1.25in}{\hspace*{\fill}Mozilla Firefox\hspace*{\fill}}}
    & \fbox{\rotatebox[origin=c]{-45}{\includegraphics[totalheight=1.25in]{example-image-10x16}}}
    & \fbox{\rotatebox[origin=c]{-45}{\includegraphics[totalheight=1.25in]{example-image-10x16}}}
    & \fbox{\rotatebox[origin=c]{-45}{\includegraphics[totalheight=1.25in]{example-image-10x16}}}

    \tabularnewline[4ex]

     \rotatebox{90}{\parbox[t]{1.25in}{\hspace*{\fill}Apple Safari\hspace*{\fill}}}
    & \fbox{\rotatebox[origin=c]{-45}{\includegraphics[totalheight=1.25in]{example-image-10x16}}}
    & \fbox{\rotatebox[origin=c]{-45}{\includegraphics[totalheight=1.25in]{example-image-10x16}}}
    & {\includegraphics[height=1.25in]{example-image-10x16}}

\end{tabular}
\end{document}

在此处输入图片描述

我没有您提到的图像。所以,我不知道它们是否已经旋转。这意味着您可能不需要在调用\rotatebox中使用\includegraphics。如果您不需要进行该调用,则可以更改totalheight为直接。不过需要注意的是,如果您传递给包height,图像不会按预期缩放:因此我从包中调用图像。demographicxmwe

我相信对齐时发生的部分原因是您位于图像基线的中心,也就是图像的底部。

我对您的方法进行了一些multirow尝试。我无法获得令人满意的结果。所以我建议放弃这个想法。

答案2

你不需要multirowparbox会做的。:

\documentclass{article}
\usepackage[demo]{graphicx}
\begin{document}
  \begin{tabular}{cccc}

    \noalign{\vskip\doublerulesep}

    & CSS & Canvas & SVG

    \tabularnewline[\doublerulesep]

    \rotatebox{90}{\parbox[t]{1in}{Google Chrome}}
    & \includegraphics[width=1in]{images/screenshots/chrome_css3}
    & \includegraphics[width=1in]{images/screenshots/chrome_canvas}
    & \includegraphics[width=1in]{images/screenshots/chrome_svg}

    \tabularnewline[\doublerulesep]

     \rotatebox{90}{\parbox[t]{1in}{Opera}}
    & \includegraphics[width=1in]{images/screenshots/opera_css3}
    & \includegraphics[width=1in]{images/screenshots/opera_canvas}
    & \includegraphics[width=1in]{images/screenshots/opera_svg}

    \tabularnewline[\doublerulesep]

     \rotatebox{90}{\parbox[t]{1in}{Mozilla Firefox}}
    & \includegraphics[width=1in]{images/screenshots/firefox_css3}
    & \includegraphics[width=1in]{images/screenshots/firefox_canvas}
    & \includegraphics[width=1in]{images/screenshots/firefox_svg}

    \tabularnewline[\doublerulesep]

     \rotatebox{90}{\parbox[t]{1in}{Apple Safari}}
    & \includegraphics[width=1in]{images/screenshots/safari_css3}
    & \includegraphics[width=1in]{images/screenshots/safari_canvas}
    & \includegraphics[width=1in]{images/screenshots/safari_svg}

\end{tabular}
\end{document}

在此处输入图片描述

相关内容