我试图在附录页面插入一个长字表,该表包含 40 多个调查问题。但是,我收到了类似这样的信息,截图如下:
代码如下:{表格太长,我将表格分成多页,并在每一页上重复标题,并希望保留这种方式}
\begin{longtable}[c]{ccl}\hline
Item & Questionnaire Items & \multicolumn{1}{c}{\begin{tabular}[c]{@{}c@{}}Questionnaire \\ Contents\end{tabular}} \\ \hline \endfirsthead
\multicolumn{3}{c}{{\bfseries Table \thetable\ continued from previous page}} \\ \hline Item & Questionnaire Items & \multicolumn{1}{c}{\begin{tabular}[c]{@{}c@{}}Questionnaire \\ Contents\end{tabular}} \\ \hline \endhead
\hline \endfoot \endlastfoot
Self-Efficacy & SE1 & To what extend do you feel comfortable with online learning environments during the COVID-19 pandemic period? \\
& SE2 & How comfortable are you in using learning management platform? (e.g. Moodle, Canvas, Blackboard, etc.)? \\
& SE3 & Please rate the effectiveness of your learning when using e-learning system during the COVID-19 pandemic. \\
& SE4 & I believe that I can achieve my learning goals using online learning environments effectively. \\
& SE5 & My self-efficacy in online learning positively impacts my motivation to participate actively in courses. \\
Anxiety & AX1 & Working on a computer during the lockdown makes me feel uncomfortable and stressed. \\
& AX2 & I experience feelings of anxiety and stress while using the online learning system during the lockdown. \\
& AX3 & I find it challenging to cope with the demands of technology usage during the lockdown. \\
& AX4 & I feel confident and at ease when operating computer-based tools and applications during the lockdown. \\
& AX5 & The use of digital devices and online platforms adds to my overall stress levels during the lockdown. \\ \hline
\end{longtable}
感谢您的帮助。
答案1
欢迎来到 TeX.Se!
由于您不知道文档序言的相关部分,因此我使用article
文档类并在 MWE(最小工作示例)中添加编译表格所需的包。因此,您的实际文档表格可能会有所不同。
使用xltabular
、ragged2e
和makecell
包代替包longtable
:
\documentclass{article}
\usepackage{ragged2e}
\usepackage{booktabs, makecell}
\usepackage{xltabular}
\begin{document}
\begin{xltabular}{\linewidth}{l c >{\RaggedRight}X}
\toprule
Item & \makecell{Questionnaire\\ Items}
& \makecell{Questionnaire\\ Contents} \\
\midrule
\endfirsthead
\toprule
Item & \makecell{Questionnaire\\ Items}
& \makecell{Questionnaire\\ Contents} \\
\midrule
\endhead
\bottomrule
\endfoot
\endlastfoot
Self-Efficacy
& SE1 & To what extend do you feel comfortable with online learning environments during the COVID-19 pandemic period?
\\
& SE2 & How comfortable are you in using learning management platform? (e.g. Moodle, Canvas, Blackboard, etc.)?
\\
& SE3 & Please rate the effectiveness of your learning when using e-learning system during the COVID-19 pandemic.
\\
& SE4 & I believe that I can achieve my learning goals using online learning environments effectively.
\\
& SE5 & My self-efficacy in online learning positively impacts my motivation to participate actively in courses.
\\
\addlinespace
Anxiety & AX1 & Working on a computer during the lockdown makes me feel uncomfortable and stressed.
\\
& AX2 & I experience feelings of anxiety and stress while using the online learning system during the lockdown.
\\
& AX3 & I find it challenging to cope with the demands of technology usage during the lockdown.
\\
& AX4 & I feel confident and at ease when operating computer-based tools and applications during the lockdown.
\\
& AX5 & The use of digital devices and online platforms adds to my overall stress levels during the lockdown.
\\
% copy, that table is longer than one page
\addlinespace
Anxiety & AX1 & Working on a computer during the lockdown makes me feel uncomfortable and stressed.
\\
& AX2 & I experience feelings of anxiety and stress while using the online learning system during the lockdown.
\\
& AX3 & I find it challenging to cope with the demands of technology usage during the lockdown.
\\
& AX4 & I feel confident and at ease when operating computer-based tools and applications during the lockdown.
\\
& AX5 & The use of digital devices and online platforms adds to my overall stress levels during the lockdown.
\\
\bottomrule
\end{xltabular}
\end{document}
或者使用tabularray
和˙ragged2e`包:
\documentclass{article}
\usepackage{ragged2e}
\usepackage{tabularray}
\UseTblrLibrary{amsmath, booktabs}
\SetTblrStyle{contfoot}{font=\footnotesize\itshape}
\SetTblrStyle{note}{font=\small}
\begin{document}
\begingroup
\DefTblrTemplate{capcont}{default}{}
\begin{longtblr}[
entry=none, % <---
label=none, % <---
]{colspec = { Q[l] Q[c] X[cmd=\RaggedRight] },
row{1} = {m},
rowhead = 1
}
% column headers
\toprule
Item & {Questionnaire\\ Items}
& Questionnaire Contents \\
\midrule
Self-Efficacy
& SE1 & To what extend do you feel comfortable with online learning environments during the COVID-19 pandemic period?
\\
& SE2 & How comfortable are you in using learning management platform? (e.g. Moodle, Canvas, Blackboard, etc.)?
\\
& SE3 & Please rate the effectiveness of your learning when using e-learning system during the COVID-19 pandemic.
\\
& SE4 & I believe that I can achieve my learning goals using online learning environments effectively.
\\
& SE5 & My self-efficacy in online learning positively impacts my motivation to participate actively in courses.
\\
\addlinespace
Anxiety & AX1 & Working on a computer during the lockdown makes me feel uncomfortable and stressed.
\\
& AX2 & I experience feelings of anxiety and stress while using the online learning system during the lockdown.
\\
& AX3 & I find it challenging to cope with the demands of technology usage during the lockdown.
\\
& AX4 & I feel confident and at ease when operating computer-based tools and applications during the lockdown.
\\
& AX5 & The use of digital devices and online platforms adds to my overall stress levels during the lockdown.
\\
% copy, that table is longer than one page
\addlinespace
Anxiety & AX1 & Working on a computer during the lockdown makes me feel uncomfortable and stressed.
\\
& AX2 & I experience feelings of anxiety and stress while using the online learning system during the lockdown.
\\
& AX3 & I find it challenging to cope with the demands of technology usage during the lockdown.
\\
& AX4 & I feel confident and at ease when operating computer-based tools and applications during the lockdown.
\\
& AX5 & The use of digital devices and online platforms adds to my overall stress levels during the lockdown.
\\
\bottomrule
\end{longtblr}
\endgroup
\end{document}
- 两种情况下表格水平线均使用
booktabs
包中定义的规则。 - 在第二个例子中,表格(符合我的口味)更好一些,代码更简单,但编译需要花费更多时间。