![调整表格中的文字](https://linux22.com/image/406425/%E8%B0%83%E6%95%B4%E8%A1%A8%E6%A0%BC%E4%B8%AD%E7%9A%84%E6%96%87%E5%AD%97.png)
我希望最后一行(2\pi 和 4\pi)的文本位置位于行的中间。其他一切都很好,应该保持不变。
\usepackage{array,bm,amsmath}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\begin{table}
\caption{Comparisons between the 0-$\pi$ qubit and the non-compact transmon/CPB.}
\centering
\begin{tabular}{|P{3.5cm}|P{2.2cm}|P{2.2cm}|}
\hline
& \textbf{Qubit potential periodicity} & \textbf{Gate potential periodicity} \\ \hline
\textbf{The 0-}$\bm{\pi}$ \textbf{qubit [7,18]} & $\pi$ & $2\pi$ \\ \hline
\textbf{The non-compact transmon/CPB} & $2\pi$ & $4\pi$ \\ \hline
\end{tabular}
\label{table:compare}
\end{table}
我怎样才能做到这一点?
答案1
将m
单元格/列的内容垂直居中
\documentclass{article}
\usepackage{array}
\usepackage{booktabs}
\usepackage{array,bm,amsmath}
\newcolumntype{P}[1]{>{\centering\arraybackslash}m{#1}}
\begin{document}
\begin{table}
\caption{Comparisons between the 0-$\pi$ qubit and the non-compact transmon/CPB.}
\centering
\begin{tabular}{|P{3.5cm}|P{2.2cm}|P{2.2cm}|}
\hline
& \textbf{Qubit potential periodicity} & \textbf{Gate potential periodicity} \\ \hline
\textbf{The 0-}$\bm{\pi}$ \textbf{qubit [7,18]} & $\pi$ & $2\pi$ \\ \hline
\textbf{The non-compact transmon/CPB} & $2\pi$ & $4\pi$ \\ \hline
\end{tabular}
\label{table:compare}
\end{table}
\end{document}
编辑
添加了一些美化
\begin{table}
\caption{Comparisons between the 0-$\pi$ qubit and the non-compact transmon/CPB.}
\centering
\begin{tabular}{P{3.5cm}P{2.2cm}P{2.2cm}}
\hline
& \multicolumn{2}{c}{\textbf{Potential periodicity}}\\ \cline{2-3}
& \textbf{Qubit} & \textbf{Gate} \\ \hline
\textbf{The 0-}$\bm{\pi}$ \textbf{qubit [7,18]} & $\pi$ & $2\pi$ \\ \hline
\textbf{The non-compact transmon/CPB} & $2\pi$ & $4\pi$ \\ \hline
\end{tabular}
\label{table:compare}
\end{table}
\end{document}