首先我想指出的是,我是 LaTeX 的新手,但我曾在论坛上搜索过以寻求问题的答案,但毫无进展。
基本上,我想将一个表格列向右对齐,但我做不到。
我使用的代码如下:
\begin{table}[]
\caption{Measured features.}
\label{table:measured_features}
\renewcommand{\arraystretch}{1.35}
\begin{tabular}{r l}
\hline\hline
\multicolumn{1}{p{5cm}}{\textbf{Feature}}
& \multicolumn{1}{p{8.5cm}}{\textbf{Description}}\\
\hline
\multicolumn{2}{l}{\textbf{Time features}} \\ \hline
\multicolumn{1}{p{5cm}}{P\textsubscript{dur}/P\textsubscript{dur,RRnorm}}
& \multicolumn{1}{p{8.5cm}}{Pwave duration (either normalised with the current RR interval or not)} \\
\multicolumn{1}{p{5cm}}{P\textsubscript{init. dur}/P\textsubscript{fin. dur}}
& \multicolumn{1}{p{8.5cm}}{P-wave initial/final duration: from onset to peak/from peak to offset, respectively} \\
\multicolumn{1}{p{5cm}}{PQ\textsubscript{on}/ PQ\textsubscript{off}/ PQ\textsubscript{on.RRnorm}/ PQ\textsubscript{off.RRnorm}}
& \multicolumn{1}{p{8.5cm}}{ PQ interval since P-wave onset/offset. respectively (either normalised with current RR or not)} \\
\end{tabular}
\end{table}
此外,我在序言中添加了以下代码:
\usepackage{booktabs} % Beautiful simple tables
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\usepackage{multirow}
我怎样才能使左列与右侧对齐?
非常感谢!Diogo
答案1
这是你想要的吗?我简化了你的代码,加载了caption
包以在标题和表格之间留出合适的间距,并使用了更好的规则booktabs
。我不知道你想用列类型定义做什么。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs} % Beautiful simple tables
\usepackage{array}
\usepackage{ragged2e}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\usepackage{multirow, caption}
\begin{document}
\begin{table}[!htb]
\caption{Measured features.}
\label{table:measured_features}
\renewcommand{\arraystretch}{1.35}
\begin{tabular}{ >{\RaggedLeft}p{5cm} p{8.5cm}}
\toprule\midrule
\multicolumn{1}{l}{\textbf{Feature}}
& \multicolumn{1}{p{8.5cm}}{\textbf{Description}}\\
\midrule
\multicolumn{2}{l}{\textbf{Time features}} \\
\midrule
P\textsubscript{dur}/P\textsubscript{dur,RRnorm}
& Pwave duration (either normalised with the current RR interval or not) \\
%
P\textsubscript{init. dur}/P\textsubscript{fin. dur}
& P-wave initial/final duration: from onset to peak/from peak to offset, respectively \\
%
PQ\textsubscript{on}/ PQ\textsubscript{off}/ PQ\textsubscript{on.RRnorm}/ PQ\textsubscript{off.RRnorm}
& PQ interval since P-wave onset/offset. respectively (either normalised with current RR or not)\\
\bottomrule
\end{tabular}
\end{table}
\end{document}