\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{tabularx}
\begin{document}
\newcounter{question}
\setcounter{question}{0}
\newcommand\Q{%
\refstepcounter{question}
\paragraph{Question \thequestion.}
}
\newcommand\A{%
\smallskip
}
\Q Question.
\A
\begin{table}[h!]
\begin{tabular}{lll}
\hline
~ & HR application & Manufacturing application \\
\hline
Agency monitoring & \multicolumn{2}{l}{CIO over two units} \\
Agency bonding & \multicolumn{2}{l}{Units over CIO} \\
Agency residual loss & \multicolumn{2}{l}{Dissatisfaction, misunderstandings...} \\
\hline
Transaction cost & \multicolumn{2}{l}{Search company, contract stipulation, relationship with outsourcer (communications, meetings...)} \\
\hline
Decision & \multicolumn{2}{l}{Collection and communications} \\
\hline
\end{tabular}
\end{table}
\end{document}
如果文本太多,无法包含在列边距内,我该如何将表格换行到页边距内并将其集中起来并获得新行?
更新1:
\begin{tabularx}{\textwidth}{lX}
\toprule
& HR application \hfill Manufacturing application \\
\hline
Agency monitoring & CIO over two units \\
Agency bonding & Units over CIO \\
Agency residual loss & Dissatisfaction, misunderstandings... \\
Transaction cost & Search company, contract stipulation, relationship with
outsourcer communications, meetings \\
Decision & Collection and communications \\
\bottomrule
\end{tabularx}
给出以下结果
但是我需要这样做HR application
并Manufacturing application
创建两个不同的列。
这张表
\begin{tabularx}{\textwidth}{lll}
\toprule
Agency monitoring & Control employees & Control company service \\
Agency bonding & Employees' report & Company report \\
Agency residual loss & None & None \\
\hline
Transaction cost & None & Search company, establish contract \\
\hline
Decision & Collection of KPIs, cleaning logs & Collection of KPIs, cleaning logs \\
\hline
KPI1 - Cost & Cost of employees and equipment & Cost of service \\
KPI2 - Quality & \multicolumn{2}{l}{Level of cleanness} \\
KPI3 - Frequency & \multicolumn{2}{l}{Frequency of cleaning, n times per week a place is cleaned} \\
\bottomrule
\end{tabularx}
包括超出表格边距的文本列。是否可以将所有两个表格与段落对齐?
答案1
这就是你要找的东西吗
\documentclass{article}
\usepackage{caption,tabularx,booktabs}
\usepackage[table]{xcolor}
\usepackage{showframe}
\usepackage{multirow}
\begin{document}
\begin{table}
\rowcolors{2}{gray!25}{white}
\begin{tabularx}{\textwidth}{lXl}
\hline \rowcolor{green!20}
& HR application & Manufacturing application \\
Agency monitoring & CIO over two units & \\
Agency bonding & Units over CIO & \\
Agency residual loss & Dissatisfaction, misunderstandings...& \\
Transaction cost & Search company, contract stipulation, relationship
with outsourcer communications, meetings &\\
Decision & Collection and communications &\\ \hline
\end{tabularx}
\end{table}
\end{document}
或者
\begin{tabularx}{\textwidth}{lX}
\toprule \rowcolor{green!20}
& HR application \hfill Manufacturing application \\
Agency monitoring & CIO over two units \\
Agency bonding & Units over CIO \\
Agency residual loss & Dissatisfaction, misunderstandings... \\
Transaction cost & Search company, contract stipulation, relationship with
outsourcer communications, meetings \\
Decision & Collection and communications \\ \bottomrule
\end{tabularx}
答案2
目前尚不清楚第三列单元格中的文本是否与第二列中的文本长度大致相等,但我预计是这样的。因此,我选择两列的宽度相等X
:
\documentclass{article}
\usepackage{caption}
\usepackage{ragged2e} % <--- for smart hyphenation of cell's contents
\usepackage{booktabs, makecell, tabularx}
\renewcommand\theadfont{\normalsize}
\renewcommand\theadgape{}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\begin{document}
\begin{table}
\setcellgapes{2pt} % <---
\makegapedcells % <--- for more vertical spaces around thext in cells
\begin{tabularx}{\textwidth}{@{} l *{2}{>{\RaggedRight}X} @{}}
\toprule
& \multicolumn{2}{c}{\thead{Application}} \\
\cmidrule(l){2-3}
& \thead{HR} & \thead{Manufacturing} \\
\midrule
Agency monitoring & CIO over two units & \\
Agency bonding & Units over CIO & \\
Agency residual loss
& Dissatisfaction, misunderstandings \dots
& \\
Transaction cost & Search company, contract stipulation,
relationship with outsourcer communications, meetings
& \\
Decision & Collection and communications
& \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}