![如何在 ACM 主文章模板中的表中添加换行符?](https://linux22.com/image/399575/%E5%A6%82%E4%BD%95%E5%9C%A8%20ACM%20%E4%B8%BB%E6%96%87%E7%AB%A0%E6%A8%A1%E6%9D%BF%E4%B8%AD%E7%9A%84%E8%A1%A8%E4%B8%AD%E6%B7%BB%E5%8A%A0%E6%8D%A2%E8%A1%8C%E7%AC%A6%EF%BC%9F.png)
所以我必须使用这个“ACM 主文章模板”来完成我的大学作业,并且我选择写一篇“系统评价”。
但我在创建所包含研究的表格时遇到了一些问题。
我正在使用该表作为模板来创建我自己的包含研究的表。
这是我目前拥有的代码:
\usepackage{pdflscape}
\pagebreak
\begin{landscape}
{\renewcommand\arraystretch{1.25}}
\begin{table}
\caption{Characteristics of the included studies}
\label{tab:freq}
\begin{tabular}{llllllllll}
\toprule
\textbf{Study} & \textbf{Country} & \textbf{Age (Years)} & \textbf{Setting} & \textbf{Sample Size} & \textbf{Study Design} & \textbf{Description of Intervention} & \textbf{Comparison} & \textbf{Duration} & \textbf{Outcome of Measures}\\
\midrule
Fernández-Real 2012 & Spain & 55-80 & PREDIMED study centre & 127 & RCT & Participants were randomly assigned to the MD + EVOO and MD + NUTS group; dietitians gave personalized dietary advice to participants corresponding to different diets & Control group (low-fat diet) & 2 years & Total osteocalcin; procollagen 1 N-terminal propeptide levels; homeostasis model assessment-β-cell function\\
\midrule
Lorefält 2012 & Sweden & 83.8$\pm$ 7.7 years & Residential homes & 67 & Within-subjects design & A multifaceted intervention model including education on both theoretical and practical issues for staff; individualized snacks were served to the residents & Participants were their own controls & 1 year & Energy intake; Body weight; MNA score; length of night-time fasting\\
\midrule
Kimura 2013 & Japan & 65–90 & Community centre & Baseline: 141 Intervention: 92 & Cluster-RCT & Consisted of a general lecture on the importance of dietary variety and five educational sessions. & The control group was subsequently provided with the same program as a crossover intervention group & 3 months & Food intake; frequency score; dietary variety score; self-rated health; appetite;\\
\midrule
Gibson 2012 & UK & 65-85 & Residential area & 82 & RCT & Intervention group: FV intake ≥5 portions/day & Normal diet (FV intake ≤2 portions/day) & 16 weeks & Changes of FV intake (Mean $\pm$ SD); antibody assessment\\
\bottomrule
\end{tabular}
\end{table}
\end{landscape}
\pagebreak
它吐出的内容如下:
我希望它看起来尽可能接近这个:
它没有换行符。我一直在尝试遵循以下指南:如何在表格单元格内添加强制换行符
问题是,仅通过添加包我就会收到这些错误:
该模板默认没有任何“\usepackage{}”。
此外,仅通过在表头标题中使用 \thead{},我就会收到“未定义的控制序列”错误。
答案1
您的表格很大……因此,为了将其放入一页,您需要减小字体大小,并尝试找到列宽。例如,正如我在以下 MWE 中所做的那样>{\hsize=...\hsize}
。在其中,我使用tabularx
列环境和L
从中定义的列X
。我还使用geometry
包来定义文本区域:
\documentclass[11pt]{article}
\usepackage[margin=20mm]{geometry} % <---
\usepackage{ragged2e} % <---
\usepackage{booktabs, makecell, tabularx} % <---
\renewcommand\theadfont{\footnotesize\bfseries} % <---
\renewcommand\theadgape{} % <---
\newcolumntype{L}{>{\RaggedRight}X} % <---
\usepackage{pdflscape}
\begin{document}
\begin{landscape}
\begin{table}
\footnotesize
\renewcommand\arraystretch{1.25}
\setlength\tabcolsep{4pt}
\caption{Characteristics of the included studies}
\label{tab:freq}
\begin{tabularx}{\linewidth}{@{} % <---
L
l
>{\hsize=0.6\hsize}L
>{\hsize=0.8\hsize}L
>{\hsize=0.8\hsize}L
>{\hsize=0.6\hsize}L
>{\hsize=1.65\hsize}L
>{\hsize=0.9\hsize}L
c
>{\hsize=1.65\hsize}L @{}}
\toprule
\thead[lb]{Study}
& \thead[lb]{Country} & \thead[lb]{Age\\ (Years)} & \thead[lb]{Setting}
& \thead[lb]{Sample\\ Size} & \thead[lb]{Study\\ Design} & \thead[lb]{Description\\ of Intervention}
& \thead[lb]{Comparison} & \thead[lb]{Duration} & \thead[lb]{Outcome\\ of Measures} \\
\midrule
Fernández-Real 2012
& Spain & 55-80 & PREDIMED study centre
& 127 & RCT & Participants were randomly assigned to the MD + EVOO and MD + NUTS group; dietitians gave personalized dietary advice to participants corresponding to different diets
& Control group (low-fat diet) & 2 years & Total osteocalcin; procollagen 1 N-terminal propeptide levels; homeostasis model assessment-β-cell function\\
\midrule
Lorefält 2012
& Sweden & $83.8\pm7.7$ years & Residential homes
& 67 & Within-subjects design & A multifaceted intervention model including education on both theoretical and practical issues for staff; individualized snacks were served to the residents & Participants were their own controls & 1 year & Energy intake; Body weight; MNA score; length of night-time fasting\\
\midrule
Kimura 2013
& Japan & 65–90 & Community centre
& Baseline: 141 Intervention: 92 & Cluster-RCT & Consisted of a general lecture on the importance of dietary variety and five educational sessions. & The control group was subsequently provided with the same program as a crossover intervention group & 3 months & Food intake; frequency score; dietary variety score; self-rated health; appetite;\\
\midrule
Gibson 2012
& UK & 65-85 & Residential area
& 82 & RCT & Intervention group: FV intake ≥5 portions/day & Normal diet (FV intake ≤2 portions/day) & 16 weeks & Changes of FV intake (Mean$\pm$SD); antibody assessment\\
\bottomrule
\end{tabularx}
\end{table}
\end{landscape}
\end{document}