我正在尝试创建两个表格:第一列应以 .25 行宽左对齐,第二列应以 .69 行宽左对齐,如果文本太长则换行。只要它们相似,列的实际宽度无关紧要。
以下代码除了左对齐外,可以完成我想要的所有操作:
\begin{table}[ht]
\begin{tabular}{p{0.25\linewidth} p{0.69\linewidth}}
\hline
\rowcolor[HTML]{EFEFEF}
Category & Description \\ \hline
Instance duration & Limits the duration in which a control-flow rule instance must hold. \\ \hline
Delay between instances & Limits the delay between two subsequent instances of a control-flow rule \\ \hline
Validity & Limits the time length in which an activity can be executed. \\ \hline
Time restricted existence & Limits the execution time of an activity based on some calendar. \\ \hline
Repetition & Limits the delay between execution of two subsequent activities. \\ \hline
Time dependent variability & Limits choice of a process path among several ones with respect to temporal aspects. \\ \hline
Overlap & Limits the start and completion of an activity w.r.t. the start and the completion of another activity. \\ \hline
\end{tabular}
\caption{\label{tab:temporal}Categorization of temporal compliance rules \cite{ramezani2017understanding, caron2013comprehensive}.}
\end{table}
如何将第一列向左对齐?
答案1
你是在要求那样的东西吗?
\documentclass[12pt,a4paper]{article}
\usepackage[table]{xcolor}
\begin{document}
\begin{table}[ht]
\begin{tabular}{>{\raggedright}p{0.25\linewidth} p{0.69\linewidth}}
\hline
\rowcolor[HTML]{EFEFEF}
Category & Description \\ \hline
Instance duration & Limits the duration in which a control-flow rule instance must hold. \\ \hline
Delay between instances & Limits the delay between two subsequent instances of a control-flow rule \\ \hline
Validity & Limits the time length in which an activity can be executed. \\ \hline
Time restricted existence & Limits the execution time of an activity based on some calendar. \\ \hline
Repetition & Limits the delay between execution of two subsequent activities. \\ \hline
Time dependent variability & Limits choice of a process path among several ones with respect to temporal aspects. \\ \hline
Overlap & Limits the start and completion of an activity w.r.t. the start and the completion of another activity. \\ \hline
\end{tabular}
\caption{\label{tab:temporal}Categorization of temporal compliance rules \cite{ramezani2017understanding, caron2013comprehensive}.}
\end{table}
\end{document}
答案2
除了强制将单元格内容排版为右边不对齐而不是完全对齐之外,您可能还想(a)切换到一个环境来最大化第二列可用的行长,以及(b)通过用包提供的指令替换大多数实例,使tabularx
表格具有更开放的“外观” 。\hline
\addlinespace
booktabs
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{ragged2e} % for '\RaggedRight' macro
\usepackage{tabularx} % for 'tabularx' env. and 'X' column type
\usepackage{booktabs} % for \addlinespace and \bottomrule macros
\begin{document}
\begin{table}[ht]
\begin{tabularx}{\textwidth}{ >{\RaggedRight}p{0.25\linewidth} >{\RaggedRight}X }
\hline
\rowcolor[HTML]{EFEFEF}
Category & Description \\ \hline \addlinespace
Instance duration & Limits the duration in which a control-flow rule instance must hold. \\ \addlinespace
Delay between instances & Limits the delay between two subsequent instances of a control-flow rule \\ \addlinespace
Validity & Limits the time length in which an activity can be executed. \\ \addlinespace
Time restricted existence & Limits the execution time of an activity based on some calendar. \\ \addlinespace
Repetition & Limits the delay between execution of two subsequent activities. \\ \addlinespace
Time dependent variability & Limits choice of a process path among several ones with respect to temporal aspects. \\ \addlinespace
Overlap & Limits the start and completion of an activity w.r.t. the start and the completion of another activity. \\
\bottomrule
\end{tabularx}
\caption{Categorization of temporal compliance rules \cite{ramezani2017understanding, caron2013comprehensive}.}
\label{tab:temporal}
\end{table}
\end{document}