-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Q42如何在设置表格列对齐方式的同时设置表格列宽? #50
Comments
之前的问题 #42 这里原来其实提供了怎么对齐的方法,但是不太特别全面,也不是最好。 我找了下之后最后给出下面的几种对齐方式:
分别使用 \newcolumntype{L}[1]{>{\RaggedRight\hspace{0pt}}m{#1}} % middle + left
\newcolumntype{C}[1]{>{\centering\arraybackslash\hspace{0pt}}m{#1}} % middle + center
\newcolumntype{R}[1]{>{\RaggedLeft\hspace{0pt}}m{#1}} % middle + right
\newcolumntype{X}[1]{>{\RaggedRight\hspace{0pt}}p{#1}} % top + left
\newcolumntype{Y}[1]{>{\centering\arraybackslash\hspace{0pt}}p{#1}} % top + center
\newcolumntype{Z}[1]{>{\RaggedLeft\hspace{0pt}}p{#1}} % top + right 根据原文的说法:
关于
|
完整的 MWE 如下: \documentclass{article}
\usepackage[a4paper, margin=1in]{geometry}
\usepackage{newtxtext}
\usepackage{array,booktabs,ragged2e}
\newcolumntype{L}[1]{>{\RaggedRight\hspace{0pt}}m{#1}} % middle + left
\newcolumntype{C}[1]{>{\centering\arraybackslash\hspace{0pt}}m{#1}} % middle + center
\newcolumntype{R}[1]{>{\RaggedLeft\hspace{0pt}}m{#1}} % middle + right
\newcolumntype{X}[1]{>{\RaggedRight\hspace{0pt}}p{#1}} % top + left
\newcolumntype{Y}[1]{>{\centering\arraybackslash\hspace{0pt}}p{#1}} % top + center
\newcolumntype{Z}[1]{>{\RaggedLeft\hspace{0pt}}p{#1}} % top + right
% ref: https://tex.stackexchange.com/questions/7347/fixed-column-width-table-with-text-left-aligned-in-cells
\begin{document}
\begin{table}
\centering
\caption{LCR with middle align}
\begin{tabular}{L{2.5cm}C{2.5cm}R{2.5cm}}
\toprule
Reconstruction Strategy (Left) & Information (Center) & bb(\%) (Right) \\
\midrule
Classic & 3342 voxels & 68 \% \\
VC & 426 voxels & 87 \% \\
$V_m=7$ & 94745 voxels & 96 \% \\
\bottomrule
\end{tabular}
\end{table}
\begin{table}
\centering
\caption{LCR with top align}
\begin{tabular}{X{2.5cm}Y{2.5cm}Z{2.5cm}}
\toprule
Reconstruction Strategy (Left) & Information (Center) & bb(\%) (Right) \\
\midrule
Classic & 3342 voxels & 68 \% \\
VC & 426 voxels & 87 \% \\
$V_m=7$ & 94745 voxels & 96 \% \\
\bottomrule
\end{tabular}
\end{table}
\begin{table}
\centering
\caption{LCR with auto hypenation}
\begin{tabular}{L{2.5cm}C{2.5cm}R{2.5cm}}
\toprule
Reconstructionxxxxxx Strategy (Left) & Information (Center) & bb(\%) (Right) \\
\midrule
Classic & 3342 voxels & 68 \% \\
VC & 426 voxels & 87 \% \\
$V_m=7$ & 94745 voxels & 96 \% \\
\bottomrule
\end{tabular}
\end{table}
\end{document} 效果如下: 参考资料: |
你之前提到的用小数点对齐怎么设置? |
我昨天说的是用 \documentclass[12pt]{article}
\usepackage{booktabs}
\begin{document}
\begin{table}[!htb]
\centering
\begin{tabular}{r@{.}lc}
\toprule
\multicolumn{2}{c}{Heading} & Modification\\
\midrule
3&141 & Text \\
16&2 & $\alpha$\\
123&456 & English \\
\bottomrule
\end{tabular}
\end{table}
\end{document} 这个 |
但是这个方法有个不好的地方是,需要将数字这列拆分成两列,我刚看了下现在有两种其他方法,第一种用
我把我前面的代码增加了 \documentclass{article}
\usepackage[a4paper, margin=1in]{geometry}
\usepackage{newtxtext}
\usepackage{array,booktabs,ragged2e}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D{.}{.}{#1}} % input sep+output sep+{x.y}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\newcolumntype{L}[1]{>{\RaggedRight\hspace{0pt}}m{#1}} % middle + left
\newcolumntype{C}[1]{>{\centering\arraybackslash\hspace{0pt}}m{#1}} % middle + center
\newcolumntype{R}[1]{>{\RaggedLeft\hspace{0pt}}m{#1}} % middle + right
\newcolumntype{X}[1]{>{\RaggedRight\hspace{0pt}}p{#1}} % top + left
\newcolumntype{Y}[1]{>{\centering\arraybackslash\hspace{0pt}}p{#1}} % top + center
\newcolumntype{Z}[1]{>{\RaggedLeft\hspace{0pt}}p{#1}} % top + right
% ref: https://tex.stackexchange.com/questions/7347/fixed-column-width-table-with-text-left-aligned-in-cells
\begin{document}
\begin{table}
\centering
\caption{LCR with middle align}
\begin{tabular}{L{2.5cm}C{2.5cm}R{2.5cm}}
\toprule
Reconstruction Strategy (Left) & Information (Center) & bb(\%) (Right) \\
\midrule
Classic & 3342 voxels & 68 \% \\
VC & 426 voxels & 87 \% \\
$V_m=7$ & 94745 voxels & 96 \% \\
\bottomrule
\end{tabular}
\end{table}
\begin{table}
\centering
\caption{LCR with top align}
\begin{tabular}{X{2.5cm}Y{2.5cm}Z{2.5cm}}
\toprule
Reconstruction Strategy (Left) & Information (Center) & bb(\%) (Right) \\
\midrule
Classic & 3342 voxels & 68 \% \\
VC & 426 voxels & 87 \% \\
$V_m=7$ & 94745 voxels & 96 \% \\
\bottomrule
\end{tabular}
\end{table}
\begin{table}
\centering
\caption{LCR with auto hypenation}
\begin{tabular}{L{2.5cm}C{2.5cm}R{2.5cm}}
\toprule
Reconstructionxxxxxx Strategy (Left) & Information (Center) & bb(\%) (Right) \\
\midrule
Classic & 3342 voxels & 68 \% \\
VC & 426 voxels & 87 \% \\
$V_m=7$ & 94745 voxels & 96 \% \\
\bottomrule
\end{tabular}
\end{table}
\begin{table}
\centering
\caption{LCR with auto hypenation}
\begin{tabular}{L{2.5cm}C{2.5cm}R{2.5cm}d{4.3}}
\toprule
Reconstructionxxxxxx Strategy (Left) & Information (Center) & bb(\%) (Right) & \mc{Decimal} \\
\midrule
Classic & 3342 voxels & 68 \% & 333.30\\
VC & 426 voxels & 87 \% & 30\\
$V_m=7$ & 94745 voxels & 96 \% & 28.1\\
\bottomrule
\end{tabular}
\end{table}
\begin{table}
\centering
\caption{LCR with decimal align}
\begin{tabular}{L{2.5cm}C{2.5cm}R{2.5cm}d{4.3}}
\toprule
Reconstruction Strategy (Left) & Information (Center) & bb(\%) (Right) & \mc{Decimal} \\
\midrule
Classic & 3342 voxels & 68 \% & 333.30\\
VC & 426 voxels & 87 \% & 30\\
$V_m=7$ & 94745 voxels & 96 \% & 28.1\\
\bottomrule
\end{tabular}
\end{table}
\end{document} 导言区就增加了 |
补充: |
|
No description provided.
The text was updated successfully, but these errors were encountered: