简体   繁体   English

乳胶表中的垂直对齐

[英]Vertical align in table on Latex

I want to make a table and print the text in the middle of all cases. 我想做一张桌子,并在所有情况下打印文本。 I use the array package and I wrote: 我使用数组包,并写道:

\begin{table}[H]
\begin{center}
\begin{tabular}{|m{3cm}|m{2.5cm}|m{2.5cm}|m{2.5cm}|m{6cm}|}

But then Latex says that I missed one '$' or one '{' in my table... but there is only text, so I don't understand. 但是后来Latex说我在表中错过了一个'$'或一个'{'...,但是只有文字,所以我听不懂。 When I switched to : 当我切换到:

\begin{table}[H]
\begin{center}
\begin{tabular}{|m{3cm}|C{2.5cm}|C{2.5cm}|C{2.5cm}|C{6cm}|}

all is ok and works... but it's ugly. 一切都很好并且可以工作...但是很难看。 I read a lot of stuff about that on the site already but never fixed my obvious-like problem :/ 我已经在网站上阅读了很多有关该内容的内容,但是从未解决过我类似的问题:/

Here is a minimal example of the layout I use for tables. 这是我用于表格的最小布局示例。 Different combinations of sizing and formatting are shown. 显示了大小和格式的不同组合。 I am not sure if this is what you asked for. 我不确定这是否是您要的。 Please reformulate your question, if it is not. 如果不是,请重新提出您的问题。

\documentclass{scrartcl}

\usepackage{booktabs} % \cmidrule in tables
% \usepackage{caption}  % Nice Captions
% \usepackage{longtable} % Tables larger than one page
% \usepackage{multirow} % Mergings Cells
% \usepackage{multicol} % Merging Cells
\usepackage{tabularx}

\begin{document}
\begin{table}
  \caption{Some caption, for tables always above}
  \label{some label}
  \begin{tabularx}{0.99\textwidth}{>{\centering}X>{\raggedleft}X>{\raggedleft}X>{\raggedleft}p{0.5cm}>{\raggedleft}p{3cm}>{\raggedright}X>{\raggedleft\arraybackslash}X}
    \toprule
    \textsc{Foobar} & $a$ & $b$ & $c$ & $d$ & $e$ & $f$ \\
    \cmidrule(r){1-1} \cmidrule(lr){2-2} \cmidrule(lr){3-3} \cmidrule(lr){4-4} \cmidrule(lr){5-5} \cmidrule(lr){6-6} \cmidrule(l){7-7}
    1               & 2   & 2   & 2   & 2   & 2   & 2   \\
    2               & 4   & 5   & 4   & 4   & 4   & 4   \\
    3               & 4   & 3   & 4   & 3   & 3   & 3   \\
    \bottomrule
  \end{tabularx}
\end{table}
\end{document}

PDF

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM