如何使多行表格单元格中的文本垂直居中?

如何使多行表格单元格中的文本垂直居中?

我想要垂直居中“Apple iPad”。

这里有人知道怎么做吗?

在此处输入图片描述

我的代码如下:

\begin{table}[H]
  \noindent 
    \centering{}
      \begin{tabular}{cc}
      \hline
            \noalign{\vskip\doublerulesep}
      Modellname & Display-Auflösung \\ ~ & (in Pixel)
            \tabularnewline[\doublerulesep]
      \hline
      Samsung Galaxy SIII & 1280x720
            \tabularnewline[\doublerulesep]         

      Samsung Galaxy SII & 800x480
            \tabularnewline[\doublerulesep]

      Apple iPad & 1024x768 (Standard)
      \\ ~ & 2048x1536 (Retina)
            \tabularnewline[\doublerulesep]         

      Samsung Galaxy Tab 2 (7.0) & 1280x720
            \tabularnewline[\doublerulesep]         

      Samsung Galaxy Y & 320x240
            \tabularnewline[\doublerulesep]         

      Sony Ericsson Xperia Arc HD & 1280x720
            \tabularnewline[\doublerulesep]

      Amazon Kindle Fire & 1024x600
            \tabularnewline[\doublerulesep]

      Google Nexus 7 & 1280x800
            \tabularnewline[\doublerulesep]         

      SamsungGalaxy Tab 2 (10.1) & 1280x720
            \tabularnewline[\doublerulesep]

      Motorola Droid Razr 4G & 960x540
            \tabularnewline[\doublerulesep]                     
      \hline
      \end{tabular}
\end{table}

答案1

一种方法是使用包裹multirow它允许您创建跨越多行的单元格:

在此处输入图片描述

笔记:

  • 我也将其应用于\multirow第一列的标题。
  • 我还将 替换x\times

代码:

\documentclass{article}
\usepackage{multirow}

\begin{document}
\begin{table}[H]
  \noindent 
    \centering{}
      \begin{tabular}{cc}
      \hline
            \noalign{\vskip\doublerulesep}
      \multirow{2}{*}{Modellname} & Display-Auflösung \\ ~ & (in Pixel)
            \tabularnewline[\doublerulesep]
      \hline
      Samsung Galaxy SIII & $1280 \times 720$
            \tabularnewline[\doublerulesep]         

      Samsung Galaxy SII & $800 \times 480$
            \tabularnewline[\doublerulesep]

      \multirow{2}{*}{Apple iPad} & $1024 \times 768$ (Standard)
      \\ ~ & $2048 \times 1536$ (Retina)
            \tabularnewline[\doublerulesep]         

      Samsung Galaxy Tab 2 (7.0) & $1280 \times 720$
            \tabularnewline[\doublerulesep]         

      Samsung Galaxy Y & $320 \times 240$
            \tabularnewline[\doublerulesep]         

      Sony Ericsson Xperia Arc HD & $1280 \times 720$
            \tabularnewline[\doublerulesep]

      Amazon Kindle Fire & $1024 \times 600$
            \tabularnewline[\doublerulesep]

      Google Nexus 7 & $1280 \times 800$
            \tabularnewline[\doublerulesep]         

      SamsungGalaxy Tab 2 (10.1) & $1280 \times 720$
            \tabularnewline[\doublerulesep]

      Motorola Droid Razr 4G & $960 \times 540$
            \tabularnewline[\doublerulesep]                     
      \hline
      \end{tabular}
\end{table}
\end{document}

相关内容