我用 xltabular 构建了以下表格。它跨越多页,中间一列文字换行。这两个功能我都想保留,因此板状的非常棒。但是,行间距对我来说太大了。
我试过\renewcommand{\arraystretch}{0.6}但它不会减少换行文本的行间距。这是我目前所得到的:
\begin{xltabular}{\textwidth}{>{\hsize=.5\hsize}X>{\hsize=1.5\hsize}X>{\hsize=1\hsize}X}
\caption{A sample long table.} \label{tab:long} \\
\hline \multicolumn{1}{c}{\textbf{Variable name}} & \multicolumn{1}{c}{\textbf{GHS categories}} & \multicolumn{1}{c}{\textbf{Indicator variable}} \\ \hline
\endfirsthead
\multicolumn{3}{c}%
{\tablename\ \thetable{} -- continued from previous page} \\
\hline \multicolumn{1}{c}{\textbf{Variable name}} & \multicolumn{1}{c}{\textbf{GHS categories}} & \multicolumn{1}{c}{\textbf{Indicator variable}} \\ \hline
\endhead
\hline \multicolumn{3}{r}{{Continued on next page}} \\ \hline
\endfoot
\hline
\endlastfoot
\texttt{EDU\_CAL} & Proficiency in calculating / working out change & \texttt{edu\_calc\_prof} \\
\texttt{EDU\_RDSN} & Proficiency in reading road signs & \texttt{edu\_rdsn\_prof} \\
\texttt{EDU\_RSNN} & Currently not attending an educational institution due to & \texttt{edu\_rsnn\_phys} \\
& physical limitations & \\
& Currently not attending due to school disruptive factors & \texttt{edu\_rsnn\_school} \\
& Currently not attending due to other commitments & \texttt{edu\_rsnn\_commit} \\
\texttt{EDU\_MODE\_TR} & Public transport is used to get to the educational institution & \texttt{edu\_public\_transport} \\
& Respondent walks to get to the educational institution & \texttt{edu\_walk\_transport} \\
& Private transport is used to get to the educational institution & \texttt{edu\_priv\_transport} \\
\texttt{EDU\_TIME} & Travel time to educational institution is more than an hour & \texttt{edu\_trans\_time\_more\_hour} \\
& Travel time to educational institution is less than an hour & \texttt{edu\_trans\_time\_less\_hour} \\
\texttt{EDU\_NEAREST} & This educational institution is the nearest to the dwelling & \texttt{edu\_nearest\_inst} \\
\texttt{EDU\_NOT\_NEAR} & School factors being the reason the nearest educational & \texttt{edu\_school\_fac\_not\_near} \\
& institution is not attended & \\
& Academic conditions being the reason the nearest & \texttt{edu\_aca\_cond\_not\_near} \\
& educational institution is not attended & \\
& Educational environment being the reason the nearest & \texttt{edu\_edu\_env\_not\_near} \\
& educational institution is not attended & \\
& Admission availability being the reason the nearest & \texttt{edu\_admission\_avail\_not\_near} \\
& educational institution is not attended & \\
\texttt{EDU\_TOT\_FEES} & Total amount of tuition fees paid is less than R1000 for & \texttt{edu\_fees\_low} \\
& the year & \\
& Total amount of tuition fees paid is between R1000 and & \texttt{edu\_fees\_med} \\
& R12000 for the year & \\
& Total amount of tuition fees paid is between R12000 and & \texttt{edu\_fees\_high} \\
& R20000 for the year & \\
& No tuition fees paid for the year & \texttt{edu\_fees\_none} \\
\texttt{EDU\_NO\_FEES} & Not paying fees due to financial status & \texttt{edu\_fin\_status\_fees} \\
& Not paying fees due to receiving financial support & \texttt{edu\_fin\_support\_no\_fees} \\
\texttt{EDU\_BURS} & Benefited from financial help, fee reduction or partial & \texttt{edu\_bursary} \\
& bursary & \\
\texttt{EDU\_PROB\_BOOK} & Lack of books / learning materials & \texttt{edu\_book} \\
\texttt{EDU\_PROB\_POOR} & Poor quality of teaching / lecturing & \texttt{edu\_poor\_teach\_qual} \\
\texttt{EDU\_PROB\_LACK} & Lack of teachers & \texttt{edu\_lack\_teachers} \\
\texttt{EDU\_PROB\_BAD\_C} & Facilities in bad condition & \texttt{edu\_fac\_bad\_cond} \\
\texttt{EDU\_PROB\_FEES} & Fees too high & \texttt{edu\_fees\_high} \\
\texttt{EDU\_PROB\_CLAS} & Classes too large / too many learners & \texttt{edu\_class\_large} \\
& Teachers/lecturers are often absent from school & \texttt{edu\_teach\_abs} \\
& Teachers/lecturers were involved in a strike & \texttt{edu\_teach\_strike} \\
\texttt{EDU\_FOOD} & School feeding scheme / government nutrition programme & \texttt{edu\_food\_school} \\
\texttt{EDU\_VLNC} & Victim of any violence, corporal punishment, or verbal & \texttt{edu\_violence} \\
& abuse at school & \\
\texttt{EDU\_ABS} & Absent from school during past school week & \texttt{edu\_absent} \\
\texttt{EDU\_ABSRSN} & Personal reasons for absenteeism & \texttt{edu\_personal\_rsn\_absent} \\
& External reasons for absenteeism & \texttt{edu\_external\_rsn\_absent} \\
& School factors reason for absenteeism & \texttt{edu\_school\_rsn\_absent} \\ \hline
\end{xltabular}
答案1
我建议采用不同的布局:一些变量指示符非常长,因此很难为 GHS 类别列保持合理的宽度。我的建议是将变量指示符放在类别说明的顶部,并留出一些水平空间使其更突出一些。
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{xltabular,ragged2e,booktabs}
\newcolumntype{L}{>{\RaggedRight}X}
\begin{document}
\begingroup % limit the scope of the next instruction
\catcode`_=12
\begin{xltabular}{\textwidth}{@{} >{\ttfamily}l >{\hangindent=1em \hangafter=1 }X @{}}
\caption{A sample long table.} \label{tab:long} \\
\toprule
\textnormal{Variable name} & Indicator variable and GHS category \\
\midrule
\endfirsthead
\multicolumn{2}{@{}c@{}}{\tablename\ \thetable, continued from previous page} \\
\addlinespace[\abovecaptionskip]
\toprule
\textnormal{Variable name} & Indicator variable and GHS category \\
\midrule
\endhead
\midrule \multicolumn{2}{@{}r@{}}{\footnotesize\itshape continued on next page} \\
\endfoot
\bottomrule
\endlastfoot
EDU_CAL
& \texttt{edu_calc_prof} \newline
Proficiency in calculating\slash working out change \\*
\addlinespace
EDU_RDSN
& \texttt{edu_rdsn_prof} \newline
Proficiency in reading road signs \\*
\addlinespace
EDU_RSNN
& \texttt{edu_rsnn_phys} \newline
Currently not attending an educational institution due to physical limitations \\*
& \texttt{edu_rsnn_school} \newline
Currently not attending due to school disruptive factors \\*
& \texttt{edu_rsnn_commit} \newline
Currently not attending due to other commitments \\
\addlinespace
EDU_MODE_TR
& \texttt{edu_public_transport} \newline
Public transport is used to get to the educational institution \\*
& \texttt{edu_walk_transport} \newline
Respondent walks to get to the educational institution \\*
& \texttt{edu_priv_transport} \newline
Private transport is used to get to the educational institution \\
\addlinespace
EDU_TIME
& \texttt{edu_trans_time_more_hour} \newline
Travel time to educational institution is more than an hour \\*
& \texttt{edu_trans_time_less_hour} \newline
Travel time to educational institution is less than an hour \\
\addlinespace
EDU_NEAREST
& \texttt{edu_nearest_inst} \newline
This educational institution is the nearest to the dwelling \\
\addlinespace
EDU_NOT_NEAR
& \texttt{edu_school_fac_not_near} \newline
School factors being the reason the nearest educational institution is not attended \\*
& \texttt{edu_aca_cond_not_near} \newline
Academic conditions being the reason the nearest educational institution is not attended \\*
& \texttt{edu_edu_env_not_near} \newline
educational environment being the reason the nearest educational institution is not attended \\*
& \texttt{edu_admission_avail_not_near} \newline
Admission availability being the reason the nearest educational institution is not attended \\
\addlinespace
EDU_TOT_FEES
& \texttt{edu_fees_low} \newline
Total amount of tuition fees paid is less than R1000 for the year \\*
& \texttt{edu_fees_med} \newline
Total amount of tuition fees paid is between R1000 and R12000 for the year \\*
& \texttt{edu_fees_high} \newline
Total amount of tuition fees paid is between R12000 and R20000 for the year \\*
& \texttt{edu_fees_none} \newline
No tuition fees paid for the year \\
\addlinespace
EDU_NO_FEES
& \texttt{edu_fin_status_fees} \newline
Not paying fees due to financial status \\*
& \texttt{edu_fin_support_no_fees} \newline
Not paying fees due to receiving financial support \\
\addlinespace
EDU_BURS
& \texttt{edu_bursary} \newline
Benefited from financial help, fee reduction or partial bursary \\*
\addlinespace
EDU_PROB_BOOK
& \texttt{edu_book} \newline
Lack of books\slash learning materials \\
\addlinespace
EDU_PROB_POOR
& \texttt{edu_poor_teach_qual} \newline
Poor quality of teaching\slash lecturing \\
\addlinespace
EDU_PROB_LACK
& \texttt{edu_lack_teachers} \newline
Lack of teachers \\
\addlinespace
EDU_PROB_BAD_C
& \texttt{edu_fac_bad_cond} \newline
Facilities in bad condition \\
\addlinespace
EDU_PROB_FEES
& \texttt{edu_fees_high} \newline
Fees too high \\
\addlinespace
EDU_PROB_CLAS
& \texttt{edu_class_large} \newline
Classes too large\slash too many learners \\*
& \texttt{edu_teach_abs} \newline
Teachers\slash lecturers are often absent from school \\*
& \texttt{edu_teach_strike} \newline
Teachers\slash lecturers were involved in a strike \\
\addlinespace
EDU_FOOD
& \texttt{edu_food_school} \newline
School feeding scheme\slash government nutrition programme \\
\addlinespace
EDU_VLNC
& \texttt{edu_violence} \newline
Victim of any violence, corporal punishment, or verbal abuse at school \\
\addlinespace
EDU_ABS
& \texttt{edu_absent} \newline
Absent from school during past school week \\
\addlinespace
EDU_ABSRSN
& \texttt{edu_personal_rsn_absent} \newline
Personal reasons for absenteeism \\*
& \texttt{edu_external_rsn_absent} \newline
External reasons for absenteeism \\*
& \texttt{edu_school_rsn_absent} \newline
School factors reason for absenteeism \\
\end{xltabular}
\endgroup
\end{document}
通过\catcode`_=12
(在组内)我们在本地省去了输入的需要\_
,从而使代码更具可读性。
同一(大写)变量下的组由一些垂直空间分隔;这样\\*
我们就可以避免在引用同一变量的块中出现奇怪的分页符。
答案2
无需设置\arraystretch
为小于 1 的值。对于第 1 列和第 3 列,我将 (a) 不允许自动换行,以及 (b) 自动使用等宽字体。我建议在第 2 行使用连续行的自动悬挂缩进。我看不出有什么理由在粗体。
\documentclass{article}
\usepackage[letterpaper,margin=1in]{geometry}
\usepackage[T1]{fontenc}
\usepackage{xltabular,ragged2e,booktabs}
\newcolumntype{L}{>{\RaggedRight}X}
\begin{document}
\begingroup % limit the scope of the next instruction
\setlength\tabcolsep{4pt}
\begin{xltabular}{\textwidth}{@{}
>{\ttfamily}l
>{\hangindent=1em\hangafter=1}L
>{\ttfamily}l @{}}
\caption{A sample long table.} \label{tab:long} \\
\toprule
\textnormal{Variable name} &
GHS categories &
\textnormal{Indicator variable} \\
\midrule
\endfirsthead
\multicolumn{3}{c}{\tablename\ \thetable, continued from previous page} \\
\addlinespace
\toprule
\textnormal{Variable name} &
GHS categories &
\textnormal{Indicator variable} \\
\midrule
\endhead
\midrule \multicolumn{3}{r@{}}{\footnotesize\itshape continued on next page} \\
\endfoot
\bottomrule
\endlastfoot
EDU\_CAL
& Proficiency in calculating\slash working out change & edu\_calc\_prof \\
EDU\_RDSN
& Proficiency in reading road signs & edu\_rdsn\_prof \\
EDU\_RSNN
& Currently not attending an educational institution due to physical limitations & edu\_rsnn\_phys \\
& Currently not attending due to school disruptive factors & edu\_rsnn\_school \\
& Currently not attending due to other commitments & edu\_rsnn\_commit \\
EDU\_MODE\_TR
& Public transport is used to get to the educational institution & edu\_public\_transport \\
& Respondent walks to get to the educational institution & edu\_walk\_transport \\
& Private transport is used to get to the educational institution & edu\_priv\_transport \\
EDU\_TIME
& Travel time to educational institution is more than an hour & edu\_trans\_time\_more\_hour \\
& Travel time to educational institution is less than an hour & edu\_trans\_time\_less\_hour \\
EDU\_NEAREST
& This educational institution is the nearest to the dwelling & edu\_nearest\_inst \\
EDU\_NOT\_NEAR
& School factors being the reason the nearest educational institution is not attended & edu\_school\_fac\_not\_near \\
& Academic conditions being the reason the nearest educational institution is not attended & edu\_aca\_cond\_not\_near \\
& Educational environment being the reason the nearest educational institution is not attended & edu\_edu\_env\_not\_near \\
& Admission availability being the reason the nearest educational institution is not attended & edu\_admission\_avail\_not\_near \\
EDU\_TOT\_FEES
& Total amount of tuition fees paid is less than R1000 for the year & edu\_fees\_low \\
& Total amount of tuition fees paid is between R1000 and R12000 for the year & edu\_fees\_med \\
& Total amount of tuition fees paid is between R12000 and R20000 for the year & edu\_fees\_high \\
& No tuition fees paid for the year & edu\_fees\_none \\
EDU\_NO\_FEES
& Not paying fees due to financial status & edu\_fin\_status\_fees \\
& Not paying fees due to receiving financial support & edu\_fin\_support\_no\_fees \\
EDU\_BURS
& Benefited from financial help, fee reduction or partial bursary & edu\_bursary \\
EDU\_PROB\_BOOK
& Lack of books\slash learning materials & edu\_book \\
EDU\_PROB\_POOR
& Poor quality of teaching\slash lecturing & edu\_poor\_teach\_qual \\
EDU\_PROB\_LACK
& Lack of teachers & edu\_lack\_teachers \\
EDU\_PROB\_BAD\_C
& Facilities in bad condition & edu\_fac\_bad\_cond \\
EDU\_PROB\_FEES
& Fees too high & edu\_fees\_high \\
EDU\_PROB\_CLAS
& Classes too large\slash too many learners & edu\_class\_large \\
& Teachers\slash lecturers are often absent from school & edu\_teach\_abs \\
& Teachers\slash lecturers were involved in a strike & edu\_teach\_strike \\
EDU\_FOOD
& School feeding scheme\slash government nutrition programme & edu\_food\_school \\
EDU\_VLNC
& Victim of any violence, corporal punishment, or verbal abuse at school & edu\_violence \\
EDU\_ABS
& Absent from school during past school week & edu\_absent \\
EDU\_ABSRSN
& Personal reasons for absenteeism & edu\_personal\_rsn\_absent \\
& External reasons for absenteeism & edu\_external\_rsn\_absent \\
& School factors reason for absenteeism & edu\_school\_rsn\_absent \\
\end{xltabular}
\endgroup
\end{document}