对于我的硕士论文,我需要为我的统计模型解决大量变量。由于论文有一些页边距限制,我使用 longtable 将表格有效地分成几页。我对结果很不满意。最后会有一个 MWE 来查看我取得了什么成果,但如果可能的话,我希望有一个更密集和更时尚的解决方案。欢迎任何建议!
PS:表格的某些部分已被注释,因为它们位于数据集中但未在模型中使用。
编辑:澄清“密集而时尚”:如果表格尽可能小而不会影响阅读质量,我将不胜感激。后者再次是一个宽泛的术语,但可以定义为表格的打印版本无需过度聚焦即可阅读。
“时尚”一词指的是表格的整体外观。我希望侧面没有缝隙。我希望底部是表格的一部分,没有多余的线条。此外,我还希望有其他样式创意,以清晰、易懂且易于阅读的设计呈现信息。
分数维:
\documentclass{article}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{geometry}[lmargin = 3 cm,rmargin = 2.5cm,tmargin=2.5cm,bmargin=2.5cm]
\begin{document}
\begin{longtable}{|l|p{5cm}|l|}
\toprule
Variable name &
Description & Variable type \\ \midrule
\endhead
%
id &
the website ID of the athlete. & \textit{factor} \\
\midrule
%date &
% Date of the the website activity & \textit{POSIXct} \\
% \midrule
distance &
Distance of the training session in km. & \textit{numeric} \\
\midrule
%mov\_time &
% The moving time feature is defined as the passed time of an activity. the website recognizes this feature in either two ways. If the athlete paused his ride during a %stop manually on the tracking device or if a rider falls under a specific (movement) threshold defined by the website. This threshold is not specified by the website publicly. %& \textit{character} \\ \midrule
elevation &
Amount of meters of the route which contains elevation. & \textit{numeric} \\
\midrule
%relativeEffort &
% Intensity across sport types. A the website specific metric which tells the athlete how intense his activity (training) was %compared other sports activities. & \textit{numeric} \\
% \midrule
avg\_power\_weig &
Adjusted avg. power of the ride where a the website algorithm corrects possible outliers in the data due to environmental impacts such as terrain, grade, wind and other factors. & \textit{numeric} \\
\midrule
work\_total &
The sum of watts generated during the rid, expressed in kilojoules(kJ). & \textit{numeric} \\
\midrule
training\_load &
Indicator for how long an athlete should rest after an activity. Power of a ride is compared to an individual functional threshold power. The latter is defined as the highest power output a road cyclist can preserve in a semisteady state for approximately 60 minutes. & \textit{numeric} \\
\midrule
intensity &
An indicator to express the level of difficulty of a ride compared to the functional threshhold power. E.g. if the weigh. avg. power was 250W and your FTP 300W the intensity would be 83\%. For short and intensive rides such as sprints values greater than 100\% are possible & \textit{numeric} \\
\midrule
estAvgPower &
Another estimate of the avg power of an activity generated by the website. No further information about the calculation was found. & \textit{numeric} \\
\midrule
avg\_speed &
Average speed of the ride. & \textit{numeric} \\
\midrule
max\_speed &
Max speed of the ride. & \textit{numeric} \\
\midrule
avg\_cadence &
Average pedalling rate, average number of revolutions of the crank during the activity. & \textit{numeric} \\
\midrule
max\_cadence &
Max pedalling rate, maximal number of revolutions of the crank during the activity. & \textit{numeric} \\
\midrule
avg\_hearRate &
Average heart rate during the ride. & \textit{numeric} \\
\midrule
max\_heartRate &
Max heart rate during the ride. & \textit{numeric} \\
\midrule
avg\_power &
Average power in watt generated during the ride. & \textit{numeric} \\
\midrule
max\_power &
Max power in watt generated during the ride. & \textit{numeric} \\
\midrule
avg\_calories &
Average calories burned during the ride. & \textit{numeric} \\
\midrule
avg\_temperature &
Average temperature during the ride. & \textit{numeric}\\
\midrule
avg\_elap\_time\_sec &
Average elapsed time in seconds during the ride. & \textit{character} \\
\midrule
age &
The age of the athlete. & \textit{numeric} \\
\midrule
type &
Categorical variable indicating if an cyclists is either of type 'climber','sprinter' or 'mixed' & \textit{factor} \\
\midrule
height &
The height of the athlete. \\
\midrule
season &
Season of the year of the activity : spring, summer, autumn, winter. & \textit{factor} \\
\midrule
year &
Categorical variable indicating the year of the activity. & \textit{factor} \\
\midrule
UCI\_points\_weekly &
Indicates the weekly UCI points an athlete had on the in that week of the training activity. & \textit{numeric} \\
\midrule
%energy\_output &
% An indicator for the amount of work an athlete has done during a ride expressed in kilojoules(KJ). Mixture of how %fast, how much and with how much force an athlete is pedaling. & \textit{numeric} \\
% \midrule
bicycle\_computer\_model &
Model of the bicycle computer. & \textit{factor} \\ \bottomrule
\label{tab:variable_list}
\end{longtable}
\end{document}
答案1
这里有两个建议。第一个更接近您的原始格式,有垂直和水平线,但通过将表格一直延伸到页边距以允许更宽的描述栏,可以更有效地利用页面。为了避免行间出现间隙,我booktabs
用\hline
命令替换了行。
第二个示例使用了一种不同的方法,更接近列表的输出description
结果。在此示例中,我还使用了较小的字体大小,并调整了表格内的水平和垂直空间。通过这些调整,您可以将整个表格放在一页上:
\documentclass{article}
\usepackage{geometry}[lmargin = 3 cm,rmargin = 2.5cm,tmargin=2.5cm,bmargin=2.5cm]
%%% Used in first and second example %%%
\usepackage{makecell}
%%% Only used in the first example%%%
\usepackage{xltabular}
\setcellgapes{2pt}
%%% only used in second example %%%
\usepackage{tabularx}
\usepackage{booktabs}
\setlength{\defaultaddspace}{3.5pt}
\begin{document}
{\makegapedcells
\renewcommand{\theadfont}{\normalsize}
\begin{xltabular}{\linewidth}{|l|X|l|}
\caption{caption text} \label{tab:variable_list}\\
\hline
\thead[l]{Variable name} &
\thead[l]{Description} &
\thead[l]{Variable\\ type} \\ \hline
\endfirsthead
\caption[]{caption text - continued from previous page}\\
\hline
\thead[l]{Variable name} &
\thead[l]{Description} &
\thead[l]{Variable\\ type} \\ \hline
\endhead
%
id &
the website ID of the athlete. & \textit{factor} \\
\hline
%date &
% Date of the the website activity & \textit{POSIXct} \\
% \hline
distance &
Distance of the training session in km. & \textit{numeric} \\
\hline
%mov\_time &
% The moving time feature is defined as the passed time of an activity. the website recognizes this feature in either two ways. If the athlete paused his ride during a %stop manually on the tracking device or if a rider falls under a specific (movement) threshold defined by the website. This threshold is not specified by the website publicly. %& \textit{character} \\ \hline
elevation &
Amount of meters of the route which contains elevation. & \textit{numeric} \\
\hline
%relativeEffort &
% Intensity across sport types. A the website specific metric which tells the athlete how intense his activity (training) was %compared other sports activities. & \textit{numeric} \\
% \hline
avg\_power\_weig &
Adjusted avg. power of the ride where a the website algorithm corrects possible outliers in the data due to environmental impacts such as terrain, grade, wind and other factors. & \textit{numeric} \\
\hline
work\_total &
The sum of watts generated during the rid, expressed in kilojoules(kJ). & \textit{numeric} \\
\hline
training\_load &
Indicator for how long an athlete should rest after an activity. Power of a ride is compared to an individual functional threshold power. The latter is defined as the highest power output a road cyclist can preserve in a semisteady state for approximately 60 minutes. & \textit{numeric} \\
\hline
intensity &
An indicator to express the level of difficulty of a ride compared to the functional threshhold power. E.g. if the weigh. avg. power was 250W and your FTP 300W the intensity would be 83\%. For short and intensive rides such as sprints values greater than 100\% are possible & \textit{numeric} \\
\hline
estAvgPower &
Another estimate of the avg power of an activity generated by the website. No further information about the calculation was found. & \textit{numeric} \\
\hline
avg\_speed &
Average speed of the ride. & \textit{numeric} \\
\hline
max\_speed &
Max speed of the ride. & \textit{numeric} \\
\hline
avg\_cadence &
Average pedalling rate, average number of revolutions of the crank during the activity. & \textit{numeric} \\
\hline
max\_cadence &
Max pedalling rate, maximal number of revolutions of the crank during the activity. & \textit{numeric} \\
\hline
avg\_hearRate &
Average heart rate during the ride. & \textit{numeric} \\
\hline
max\_heartRate &
Max heart rate during the ride. & \textit{numeric} \\
\hline
avg\_power &
Average power in watt generated during the ride. & \textit{numeric} \\
\hline
max\_power &
Max power in watt generated during the ride. & \textit{numeric} \\
\hline
avg\_calories &
Average calories burned during the ride. & \textit{numeric} \\
\hline
avg\_temperature &
Average temperature during the ride. & \textit{numeric}\\
\hline
avg\_elap\_time\_sec &
Average elapsed time in seconds during the ride. & \textit{character} \\
\hline
age &
The age of the athlete. & \textit{numeric} \\
\hline
type &
Categorical variable indicating if an cyclists is either of type 'climber','sprinter' or 'mixed' & \textit{factor} \\
\hline
height &
The height of the athlete. & \\
\hline
season &
Season of the year of the activity : spring, summer, autumn, winter. & \textit{factor} \\
\hline
year &
Categorical variable indicating the year of the activity. & \textit{factor} \\
\hline
UCI\_points\_weekly &
Indicates the weekly UCI points an athlete had on the in that week of the training activity. & \textit{numeric} \\
\hline
%energy\_output &
% An indicator for the amount of work an athlete has done during a ride expressed in kilojoules(KJ). Mixture of how %fast, how much and with how much force an athlete is pedaling. & \textit{numeric} \\
% \hline
bicycle\_computer\_model &
Model of the bicycle computer. & \textit{factor} \\ \hline
\end{xltabular}
}
\begin{table}
\small
\renewcommand{\theadfont}{\small}
\caption{caption text}\label{tab:variable_list}
\begin{tabularx}{\linewidth}{@{}>{\hangindent=1em}X>{\itshape}l@{}}
\toprule
\thead[l]{\textbf{Variable name} Description}&
\upshape\thead[l]{Variable\\ type} \\
\midrule
\textbf{id}
the website ID of the athlete.
& factor \\
\addlinespace
\textbf{distance}
Distance of the training session in km.
& numeric \\
\addlinespace
\textbf{elevation}
Amount of meters of the route which contains elevation.
& numeric \\
\addlinespace
\textbf{avg\_power\_weig}
Adjusted avg. power of the ride where a the website algorithm corrects possible outliers in the data due to environmental impacts such as terrain, grade, wind and other factors.
& numeric \\
\addlinespace
\textbf{work\_total}
The sum of watts generated during the rid, expressed in kilojoules(kJ).
& numeric \\
\addlinespace
\textbf{training\_load}
Indicator for how long an athlete should rest after an activity. Power of a ride is compared to an individual functional threshold power. The latter is defined as the highest power output a road cyclist can preserve in a semisteady state for approximately 60 minutes.
& numeric \\
\addlinespace
\textbf{intensity}
An indicator to express the level of difficulty of a ride compared to the functional threshhold power. E.g. if the weigh. avg. power was 250W and your FTP 300W the intensity would be 83\%. For short and intensive rides such as sprints values greater than 100\% are possible
& numeric \\
\addlinespace
\textbf{estAvgPower}
Another estimate of the avg power of an activity generated by the website. No further information about the calculation was found.
& numeric \\
\addlinespace
\textbf{avg\_speed}
Average speed of the ride.
& numeric \\
\addlinespace
\textbf{max\_speed}
Max speed of the ride.
& numeric \\
\addlinespace
\textbf{avg\_cadence}
Average pedalling rate, average number of revolutions of the crank during the activity.
& numeric \\
\addlinespace
\textbf{max\_cadence}
Max pedalling rate, maximal number of revolutions of the crank during the activity.
& numeric \\
\addlinespace
\textbf{avg\_hearRate}
Average heart rate during the ride.
& numeric \\
\addlinespace
\textbf{max\_heartRate}
Max heart rate during the ride.
& numeric \\
\addlinespace
\textbf{avg\_power}
Average power in watt generated during the ride.
& numeric \\
\addlinespace
\textbf{max\_power}
Max power in watt generated during the ride.
& numeric \\
\addlinespace
\textbf{avg\_calories}
Average calories burned during the ride.
& numeric \\
\addlinespace
\textbf{avg\_temperature}
Average temperature during the ride.
& numeric\\
\addlinespace
\textbf{avg\_elap\_time\_sec}
Average elapsed time in seconds during the ride.
& character \\
\addlinespace
\textbf{age}
The age of the athlete.
& numeric \\
\addlinespace
\textbf{type}
Categorical variable indicating if an cyclists is either of type 'climber','sprinter' or 'mixed'
& factor \\
\addlinespace
\textbf{height}
The height of the athlete. \\
\addlinespace
\textbf{season}
Season of the year of the activity : spring, summer, autumn, winter.
& factor \\
\addlinespace
\textbf{year}
Categorical variable indicating the year of the activity.
& factor \\
\addlinespace
\textbf{UCI\_points\_weekly}
Indicates the weekly UCI points an athlete had on the in that week of the training activity.
& numeric \\
\addlinespace
\textbf{bicycle\_computer\_model}
Model of the bicycle computer.
& factor \\ \bottomrule
\end{tabularx}
\end{table}
\end{document}
答案2
使用该tabularray
包。
\documentclass{article}
\usepackage{geometry}[lmargin = 3 cm,rmargin = 2.5cm,tmargin=2.5cm,bmargin=2.5cm]
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\NewTblrTheme{MyTheme}{
\DefTblrTemplate{contfoot}{FootRule}{%
\bottomrule%
}
\SetTblrTemplate{contfoot}{FootRule}%
\DefTblrTemplate{caption}{NoCaption}{%
%
}
\SetTblrTemplate{caption}{NoCaption}%
\DefTblrTemplate{conthead}{NoContHead}{%
%
}
\SetTblrTemplate{conthead}{NoContHead}%
\DefTblrTemplate{capcont}{NoCapCont}{%
%
}%
\SetTblrTemplate{capcont}{NoCapCont}{%
}%
}
\begin{document}
\begin{longtblr}[
theme={MyTheme},
label={tab:variable_list},
]{
stretch = 1.5,
colspec = {@{}X[0.5,l,m] X[l,m] X[0.25,l,m]@{}},
column{1}={font=\bfseries},
column{3}={font=\em},
row{1} = {font=\normalfont},
rowhead = 1,
}
\toprule
Variable name &
Description & Variable type \\ \midrule%
id &
the website ID of the athlete. & factor \\
%\midrule
%date &
% Date of the the website activity & {POSIXct} \\
% %\midrule
distance &
Distance of the training session in km. & numeric \\
%\midrule
%mov\_time &
% The moving time feature is defined as the passed time of an activity. the website recognizes this feature in either two ways. If the athlete paused his ride during a %stop manually on the tracking device or if a rider falls under a specific (movement) threshold defined by the website. This threshold is not specified by the website publicly. %& {character} \\ %\midrule
elevation &
Amount of meters of the route which contains elevation. & numeric \\
%\midrule
%relativeEffort &
% Intensity across sport types. A the website specific metric which tells the athlete how intense his activity (training) was %compared other sports activities. & numeric \\
% %\midrule
avg\_power\_weig &
Adjusted avg. power of the ride where a the website algorithm corrects possible outliers in the data due to environmental impacts such as terrain, grade, wind and other factors. & numeric \\
%\midrule
work\_total &
The sum of watts generated during the rid, expressed in kilojoules(kJ). & numeric \\
%\midrule
training\_load &
Indicator for how long an athlete should rest after an activity. Power of a ride is compared to an individual functional threshold power. The latter is defined as the highest power output a road cyclist can preserve in a semisteady state for approximately 60 minutes. & numeric \\
%\midrule
intensity &
An indicator to express the level of difficulty of a ride compared to the functional threshhold power. E.g. if the weigh. avg. power was 250W and your FTP 300W the intensity would be 83\%. For short and intensive rides such as sprints values greater than 100\% are possible & numeric \\
%\midrule
estAvgPower &
Another estimate of the avg power of an activity generated by the website. No further information about the calculation was found. & numeric \\
%\midrule
avg\_speed &
Average speed of the ride. & numeric \\
%\midrule
max\_speed &
Max speed of the ride. & numeric \\
%\midrule
avg\_cadence &
Average pedalling rate, average number of revolutions of the crank during the activity. & numeric \\
%\midrule
max\_cadence &
Max pedalling rate, maximal number of revolutions of the crank during the activity. & numeric \\
%\midrule
avg\_hearRate &
Average heart rate during the ride. & numeric \\
%\midrule
max\_heartRate &
Max heart rate during the ride. & numeric \\
%\midrule
avg\_power &
Average power in watt generated during the ride. & numeric \\
%\midrule
max\_power &
Max power in watt generated during the ride. & numeric \\
%\midrule
avg\_calories &
Average calories burned during the ride. & numeric \\
%\midrule
avg\_temperature &
Average temperature during the ride. & numeric\\
%\midrule
avg\_elap\_time\_sec &
Average elapsed time in seconds during the ride. & {character} \\
%\midrule
age &
The age of the athlete. & numeric \\
%\midrule
type &
Categorical variable indicating if an cyclists is either of type 'climber','sprinter' or 'mixed' & factor \\
%\midrule
height &
The height of the athlete. \\
%\midrule
season &
Season of the year of the activity : spring, summer, autumn, winter. & factor \\
%\midrule
year &
Categorical variable indicating the year of the activity. & factor \\
%\midrule
UCI\_points\_weekly &
Indicates the weekly UCI points an athlete had on the in that week of the training activity. & numeric \\
%\midrule
%energy\_output &
% An indicator for the amount of work an athlete has done during a ride expressed in kilojoules(KJ). Mixture of how %fast, how much and with how much force an athlete is pedaling. & numeric \\
% %\midrule
bicycle\_computer\_model &
Model of the bicycle computer. & factor \\ \bottomrule
\end{longtblr}
\end{document}
第一页:
第二页: