LaTeX 表格:如何确保单元格中的文本不会丢失?
LaTeX tables: How to make sure text in a cell doesn't get out it?
我的一些销售的文字溢出了下一个。如何确保文本在同一个单元格内换行?
此外,如何使第一列比其他列更宽?
这是我的代码:
\documentclass[12pt,oneside,final]{vlsithesis}
\doctype{Thesis}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{layout}
\usepackage[algo2e, ruled, vlined]{algorithm2e}
\usepackage{tabularray}
\usepackage{makecell}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{rotating}
\usepackage{tabularx}
\geometry{
a4paper,
total={170mm,257mm},
left=25.4 mm,
right= 25.4mm,
top=20mm,
}
\begin{document}
\begin{table}[H]
\begin{tblr}{ colspec{|X[valign=h]|X[valign=m]|X[valign=m]|X[valign=m]|X[valign=m]|X[valign=m]|X[valign=m]|X[valign=m]|},
row{1}={font=\bfseries},
cell{1}{1}={halign=c}
}
\hline
Variables & N & Mean & SD & Min & Max & Range & SE \
\hline
ICT index & 51.00 & 16.46 & 3.89 & 8.89 & 25.59 & 16.70 & 0.54 \
\hline
Educational Resilience & 51.00 & 455.73 & 186.32 & 97.00 & 879.00 & 782.00 & 26.09 \
\hline
Log GDP per capita & 50.00 & 9.83 & 0.90 & 8.35 & 11.66 & 3.31 & 0.13 \
\hline
Literacy Rate & 50.00 & 97.95 & 1.91 & 93.23 & 99.96 & 6.73 & 0.27 \
\hline
Strengh of health system index & 50.00 & 6.08 & 1.60 & 3.00 & 9.00 & 6.00 & 0.23 \
\hline
COVID-19 cases & 50.00 & 276155.28 & 783990.64 & 1366.38 & 5012137.53 & 5010771.15 & 110873.02 \
\hline
COVID-19 deaths & 50.00 & 9240.03 & 23148.98 & 10.65 & 135930.19 & 135919.54 & 3273.76 \
\hline
Stringency index & 50.00 & 55.45 & 9.47 & 34.47 & 75.66 & 41.19 & 1.34 \
\hline
Government Response & 50.00 & 52.29 & 6.24 & 37.13 & 65.87 & 28.74 & 0.88 \
\hline
Containtment of the virus & 50.00 & 52.13 & 7.50 & 35.23 & 69.06 & 33.83 & 1.06 \
\hline
Economic Support & 50.00 & 53.40 & 16.18 & 18.26 & 83.26 & 65.00 & 2.29 \
\hline
Health Policy Index (2020) & 48.00 & 8.65 & 1.23 & 6.13 & 11.32 & 5.19 & 0.18 \
\hline
Critical Fatality Ratio (squared) & 50.00 & 15.69 & 7.08 & 5.56 & 45.25 & 39.69 & 1.00 \
\hline
\end{tblr}
\caption{Summary Statistics}
\label{table:2}
\end{table}
\end{document}
这是目前的样子:
提前致谢
长数字不能跨行,您的页面只有这么多可用 space。一些策略仍然适合您的 table 在页面上:
注意重要数字。给定标准偏差的值,将所有数字都保留两位小数是没有意义的
减少垂直线周围的填充(或者更好的是,查看 booktabs 用户指南,其中显示了 tables 的专业外观(有一个用于 tabularray 的库, 所以同样的布局也可以用这个包来完成))
改变列宽的比例,例如第一列 X[1.3,valign=h,halign=l]
使用较小的字体
缩小边距
使用更大的纸张
我昨天已经在想这个了,但是如果 table 的其余部分都左对齐,那么 1-1 单元格居中是不是很奇怪?
\documentclass[12pt,oneside,final]{article}
%\doctype{Thesis}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{layout}
\usepackage[algo2e, ruled, vlined]{algorithm2e}
\usepackage{tabularray}
\usepackage{makecell}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{rotating}
\usepackage{tabularx}
\usepackage{geometry}
\geometry{
a4paper,
total={170mm,257mm},
% left=25.4 mm,
% right= 25.4mm,
top=20mm,
}
\begin{document}
\begin{table}[H]
\small
\begin{tblr}{
colspec={|X[1.3,valign=h,halign=l]|X[valign=m]|X[valign=m]|X[valign=m]|X[valign=m]|X[valign=m]|X[valign=m]|X[valign=m]|},
row{1}={font=\bfseries},
cell{1}{1}={halign=c},
colsep=2pt
}
\hline
Variables & N & Mean & SD & Min & Max & Range & SE \
\hline
ICT index & 51.00 & 16.46 & 3.89 & 8.89 & 25.59 & 16.70 & 0.54 \
\hline
Educational Resilience & 51.00 & 455.73 & 186.32 & 97.00 & 879.00 & 782.00 & 26.09 \
\hline
Log GDP per capita & 50.00 & 9.83 & 0.90 & 8.35 & 11.66 & 3.31 & 0.13 \
\hline
Literacy Rate & 50.00 & 97.95 & 1.91 & 93.23 & 99.96 & 6.73 & 0.27 \
\hline
Strengh of health system index & 50.00 & 6.08 & 1.60 & 3.00 & 9.00 & 6.00 & 0.23 \
\hline
COVID-19 cases & 50.00 & 276155.28 & 783990.64 & 1366.38 & 5012137.53 & 5010771.15 & 110873.02 \
\hline
COVID-19 deaths & 50.00 & 9240.03 & 23148.98 & 10.65 & 135930.19 & 135919.54 & 3273.76 \
\hline
Stringency index & 50.00 & 55.45 & 9.47 & 34.47 & 75.66 & 41.19 & 1.34 \
\hline
Government Response & 50.00 & 52.29 & 6.24 & 37.13 & 65.87 & 28.74 & 0.88 \
\hline
Containtment of the virus & 50.00 & 52.13 & 7.50 & 35.23 & 69.06 & 33.83 & 1.06 \
\hline
Economic Support & 50.00 & 53.40 & 16.18 & 18.26 & 83.26 & 65.00 & 2.29 \
\hline
Health Policy Index (2020) & 48.00 & 8.65 & 1.23 & 6.13 & 11.32 & 5.19 & 0.18 \
\hline
Critical Fatality Ratio (squared) & 50.00 & 15.69 & 7.08 & 5.56 & 45.25 & 39.69 & 1.00 \
\hline
\end{tblr}
\caption{Summary Statistics}
\label{table:2}
\end{table}
\end{document}
我的一些销售的文字溢出了下一个。如何确保文本在同一个单元格内换行? 此外,如何使第一列比其他列更宽?
这是我的代码:
\documentclass[12pt,oneside,final]{vlsithesis}
\doctype{Thesis}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{layout}
\usepackage[algo2e, ruled, vlined]{algorithm2e}
\usepackage{tabularray}
\usepackage{makecell}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{rotating}
\usepackage{tabularx}
\geometry{
a4paper,
total={170mm,257mm},
left=25.4 mm,
right= 25.4mm,
top=20mm,
}
\begin{document}
\begin{table}[H]
\begin{tblr}{ colspec{|X[valign=h]|X[valign=m]|X[valign=m]|X[valign=m]|X[valign=m]|X[valign=m]|X[valign=m]|X[valign=m]|},
row{1}={font=\bfseries},
cell{1}{1}={halign=c}
}
\hline
Variables & N & Mean & SD & Min & Max & Range & SE \
\hline
ICT index & 51.00 & 16.46 & 3.89 & 8.89 & 25.59 & 16.70 & 0.54 \
\hline
Educational Resilience & 51.00 & 455.73 & 186.32 & 97.00 & 879.00 & 782.00 & 26.09 \
\hline
Log GDP per capita & 50.00 & 9.83 & 0.90 & 8.35 & 11.66 & 3.31 & 0.13 \
\hline
Literacy Rate & 50.00 & 97.95 & 1.91 & 93.23 & 99.96 & 6.73 & 0.27 \
\hline
Strengh of health system index & 50.00 & 6.08 & 1.60 & 3.00 & 9.00 & 6.00 & 0.23 \
\hline
COVID-19 cases & 50.00 & 276155.28 & 783990.64 & 1366.38 & 5012137.53 & 5010771.15 & 110873.02 \
\hline
COVID-19 deaths & 50.00 & 9240.03 & 23148.98 & 10.65 & 135930.19 & 135919.54 & 3273.76 \
\hline
Stringency index & 50.00 & 55.45 & 9.47 & 34.47 & 75.66 & 41.19 & 1.34 \
\hline
Government Response & 50.00 & 52.29 & 6.24 & 37.13 & 65.87 & 28.74 & 0.88 \
\hline
Containtment of the virus & 50.00 & 52.13 & 7.50 & 35.23 & 69.06 & 33.83 & 1.06 \
\hline
Economic Support & 50.00 & 53.40 & 16.18 & 18.26 & 83.26 & 65.00 & 2.29 \
\hline
Health Policy Index (2020) & 48.00 & 8.65 & 1.23 & 6.13 & 11.32 & 5.19 & 0.18 \
\hline
Critical Fatality Ratio (squared) & 50.00 & 15.69 & 7.08 & 5.56 & 45.25 & 39.69 & 1.00 \
\hline
\end{tblr}
\caption{Summary Statistics}
\label{table:2}
\end{table}
\end{document}
这是目前的样子:
提前致谢
长数字不能跨行,您的页面只有这么多可用 space。一些策略仍然适合您的 table 在页面上:
注意重要数字。给定标准偏差的值,将所有数字都保留两位小数是没有意义的
减少垂直线周围的填充(或者更好的是,查看 booktabs 用户指南,其中显示了 tables 的专业外观(有一个用于 tabularray 的库, 所以同样的布局也可以用这个包来完成))
改变列宽的比例,例如第一列
X[1.3,valign=h,halign=l]
使用较小的字体
缩小边距
使用更大的纸张
我昨天已经在想这个了,但是如果 table 的其余部分都左对齐,那么 1-1 单元格居中是不是很奇怪?
\documentclass[12pt,oneside,final]{article}
%\doctype{Thesis}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{layout}
\usepackage[algo2e, ruled, vlined]{algorithm2e}
\usepackage{tabularray}
\usepackage{makecell}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{rotating}
\usepackage{tabularx}
\usepackage{geometry}
\geometry{
a4paper,
total={170mm,257mm},
% left=25.4 mm,
% right= 25.4mm,
top=20mm,
}
\begin{document}
\begin{table}[H]
\small
\begin{tblr}{
colspec={|X[1.3,valign=h,halign=l]|X[valign=m]|X[valign=m]|X[valign=m]|X[valign=m]|X[valign=m]|X[valign=m]|X[valign=m]|},
row{1}={font=\bfseries},
cell{1}{1}={halign=c},
colsep=2pt
}
\hline
Variables & N & Mean & SD & Min & Max & Range & SE \
\hline
ICT index & 51.00 & 16.46 & 3.89 & 8.89 & 25.59 & 16.70 & 0.54 \
\hline
Educational Resilience & 51.00 & 455.73 & 186.32 & 97.00 & 879.00 & 782.00 & 26.09 \
\hline
Log GDP per capita & 50.00 & 9.83 & 0.90 & 8.35 & 11.66 & 3.31 & 0.13 \
\hline
Literacy Rate & 50.00 & 97.95 & 1.91 & 93.23 & 99.96 & 6.73 & 0.27 \
\hline
Strengh of health system index & 50.00 & 6.08 & 1.60 & 3.00 & 9.00 & 6.00 & 0.23 \
\hline
COVID-19 cases & 50.00 & 276155.28 & 783990.64 & 1366.38 & 5012137.53 & 5010771.15 & 110873.02 \
\hline
COVID-19 deaths & 50.00 & 9240.03 & 23148.98 & 10.65 & 135930.19 & 135919.54 & 3273.76 \
\hline
Stringency index & 50.00 & 55.45 & 9.47 & 34.47 & 75.66 & 41.19 & 1.34 \
\hline
Government Response & 50.00 & 52.29 & 6.24 & 37.13 & 65.87 & 28.74 & 0.88 \
\hline
Containtment of the virus & 50.00 & 52.13 & 7.50 & 35.23 & 69.06 & 33.83 & 1.06 \
\hline
Economic Support & 50.00 & 53.40 & 16.18 & 18.26 & 83.26 & 65.00 & 2.29 \
\hline
Health Policy Index (2020) & 48.00 & 8.65 & 1.23 & 6.13 & 11.32 & 5.19 & 0.18 \
\hline
Critical Fatality Ratio (squared) & 50.00 & 15.69 & 7.08 & 5.56 & 45.25 & 39.69 & 1.00 \
\hline
\end{tblr}
\caption{Summary Statistics}
\label{table:2}
\end{table}
\end{document}