我有这张表:
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{ltablex}
\keepXColumns
\renewcommand\tabularxcolumn[1]{ >{\arraybackslash}m{#1}}
\usepackage[table]{xcolor}
\usepackage{ragged2e}
\begin{document}
\begin{tabularx}{\textwidth}%
{| >{\hsize=1.1\hsize\columncolor{blue!10}}X|
>{\hsize=0.55\hsize}X|
>{\hsize=1.25\hsize\rule{0pt}{4ex}}X <{\mbox{}\rule[-2.5ex]{0pt}{0pt}}|
>{\hsize=1.1\hsize}X|}
\hline
\rowcolor{gray!50}\textbf{a} & \textbf{b} & \textbf{c} & \textbf{d} \\%
\hline
\endfirsthead
\hline
\endhead
\textbf{Bla bla bla}\par
\emph{jjjjj}
& r & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ut elit ac ipsum placerat scelerisque eget id justo. Ut cursus viverra neque, in porta justo facilisis sit amet. Donec vitae libero a diam lobortis ultrices. Vestibulum metus urna, pharetra et cursus quis, eleifend ut dui. Phasellus pellentesque, quam et hendrerit. & d \\
\cline{2-4}
& r & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ut elit ac ipsum placerat scelerisque eget id justo. hendrerit. & k
\\
\cline{2-4}
& g & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ut elit ac ipsum placerat scelerisque eget id justo. Ut cursus viverra neque, in porta justo facilisis sit amet. Donec vitae libero a diam lobortis ultrices. Vestibulum metus urna, pharetra et cursus quis, eleifend ut dui. Phasellus pellentesque, quam et hendrerit. & p
\\
\hline
\end{tabularx}
\end{document}
我想设置较小的文本大小,因为表格很长,我想稍微调整一下表格的大小。我想在不修改整个文档的文本大小的情况下实现这一点。可以吗?
答案1
让我详细说明并扩展@David 的回答:
- 仅适用于(长)表中的较小字体:
{\small\begin{tabularx} ... \end{tabularx}}
- 不要过度缩小字体,字体太小难以阅读
- 可以通过减少来实现略多的空间核细胞内容
tabcolsep
,例如从默认值6pt
减少到3pt
(参见下面的 MWE) - 减少单元格中的额外垂直空间
通过上述措施以及代码的一些简化,您的 MWE 变为:
\documentclass[11pt]{article}
\usepackage[margin=30mm,]{geometry}% <-- added
\usepackage[utf8]{inputenc}
\usepackage{ltablex}
\keepXColumns
\renewcommand\tabularxcolumn[1]{ >{\arraybackslash}m{#1}<{\smallskip}}% <-- changed
\usepackage[table]{xcolor}
\begin{document}
{\small%\footnotesize % don't use font size below \footnoteseze
\setlength{\tabcolsep}{3pt} % <-- added
\renewcommand{\arraystretch}{1.3} % <-- added
\setlength{\extrarowheight}{2pt} % <-- added
\begin{tabularx}{\textwidth}%
{|>{\hsize=1.10\hsize\columncolor{blue!10}}X|
>{\hsize=0.55\hsize}X|
>{\hsize=1.25\hsize}X| % <-- changed
>{\hsize=1.10\hsize}X|}
\hline
\rowcolor{gray!50}\textbf{a} & \textbf{b} & \textbf{c} & \textbf{d} \\%
\hline
\endfirsthead
\hline % <-- changed
\rowcolor{gray!50}\textbf{a} & \textbf{b} & \textbf{c} & \textbf{d} \\%
\hline
\endhead
\hline % <-- added
\endfoot
\textbf{Bla bla bla}\par
\emph{jjjjj}
& r & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ut elit ac ipsum placerat scelerisque eget id justo. Ut cursus viverra neque, in porta justo facilisis sit amet. Donec vitae libero a diam lobortis ultrices. Vestibulum metus urna, pharetra et cursus quis, eleifend ut dui. Phasellus pellentesque, quam et hendrerit.
& d \\ \cline{2-4}
& r & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ut elit ac ipsum placerat scelerisque eget id justo. hendrerit.
& k \\ \cline{2-4}
& g & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ut elit ac ipsum placerat scelerisque eget id justo. Ut cursus viverra neque, in porta justo facilisis sit amet. Donec vitae libero a diam lobortis ultrices. Vestibulum metus urna, pharetra et cursus quis, eleifend ut dui. Phasellus pellentesque, quam et hendrerit.
& p \\
\end{tabularx}
}
\end{document}
进一步改进您的表格可以实现以下目的:
- 在列定义中使用
RaggedRight
包中的 宏ragged2e
- 使用包的功能
microtype
,其影响在字体大小上是显而易见的footnotesize
:
对于上表,MWE 序言和表列定义是:
\documentclass[11pt]{article}
\usepackage[margin=30mm,]{geometry}% <-- added
\usepackage[utf8]{inputenc}
\usepackage{ltablex}
\keepXColumns
\renewcommand\tabularxcolumn[1]{ >{\arraybackslash}m{#1}<{\smallskip}}% <-- changed
\usepackage[table]{xcolor}
\usepackage{ragged2e} % <-- now used
\usepackage{microtype} % <-- added
\begin{document}
{\footnotesize
\setlength{\tabcolsep}{3pt} % <-- added
\renewcommand{\arraystretch}{1.3} % <-- added
\setlength{\extrarowheight}{2pt} % <-- added
\begin{tabularx}{\textwidth}%
{|>{\hsize=1.10\hsize\columncolor{blue!10}}X|
>{\hsize=0.55\hsize\RaggedRight}X|
>{\hsize=1.25\hsize\RaggedRight}X| % <-- changed
>{\hsize=1.10\hsize\RaggedRight}X|}
% further is the same as in the above MWE
由于不清楚您所说的文本样式是什么意思,在上面的例子中,我只考虑了字体大小的变化。也可以更改字体系列。通过选择\sffamily
,即通过
{\footnotesize\sffamily
它比使用的默认 \rmamily` 字体更窄,单元格中的文本变得更加紧凑:
答案2
是的,像\scriptsize
\tiny
\footnotesize
等等一样。