
我用來setspace
改變文字的間距。
\usepackage{setspace}
\setstretch{1.435}
方程中的間距可以透過改變來管理\arraystretch
@egreg 的方法這裡
\usepackage{etoolbox}
\pretocmd{\array}{\renewcommand{\arraystretch}{0.69686}}{}{} % 1/1.435=0.69686
或 @campa 的方法這裡
\usepackage[nodisplayskipstretch]{setspace}
\setstretch{1.435}
\everydisplay=\expandafter{\the\everydisplay\setstretch{1.0}}
\arraystretch
然而,無論哪種方式,表中的行間距都是訊號間距,不能透過更改或中的值來更改\setstretch
。
我喜歡增加一點表中的行間距而不是訊號間距。我怎樣才能做到這一點?
\documentclass{article}
\usepackage{lipsum} % just for this example
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{setspace}
\setstretch{1.435}
\usepackage{etoolbox}
\pretocmd{\array}{\renewcommand{\arraystretch}{1}}{}{} % increase a little for the row spacing in equations
\begin{document}
\lipsum*[1]
\begin{equation}
X=\begin{cases}
\frac{1}{2}, & \text{if $a=1$} \\
\frac{3}{2} & \text{otherwise}
\end{cases}
\end{equation}
\begin{table}[htbp]
\centering
\caption{Changing the row spacing in the table}
\begin{tabular}{ c c c }
\toprule
cell1 & cell2 & cell3 \\
\midrule
cell4 & cell5 & cell6 \\
cell7 & cell8 & cell9 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案1
對於多線方程式的間距,可以使用spreadlines
中的環境mathtools
。它不適用於普通cases
環境,但您可以使用mathtools
.
對於表格,您可以使用cellspace
,它定義列中單元格頂部和底部的最小垂直間距,並帶有以字母為前綴的說明符S
(或C
如果您加載siunitx
)。最後,我建議加載該caption
包,它使您能夠設置標題和浮動之間的跳過。
這是一個誇張的範例程式碼:
\documentclass{article}
\usepackage{lipsum} % just for this example
\usepackage{mathtools, empheq, nccmath}
\usepackage{booktabs, caption}
\captionsetup{skip=20pt}
\usepackage[math]{cellspace}
\renewcommand{\cellspacetoplimit}{10pt}
\renewcommand{\cellspacebottomlimit}{10pt}
\usepackage{etoolbox}
\BeforeBeginEnvironment{equation}{\begin{spreadlines}{20pt}}%{\spreadlines{20pt}}%
\AfterEndEnvironment{equation}{\end{spreadlines}}
\BeforeBeginEnvironment{empheq}{\begin{spreadlines}{20pt}}%{\spreadlines{20pt}}%
\AfterEndEnvironment{empheq}{\end{spreadlines}}
\usepackage{setspace}
\setstretch{1.435}
\pretocmd{\array}{\renewcommand{\arraystretch}{1}}{}{} % increase a little for the row spacing in equations
\begin{document}
\lipsum*[1]
\begin{equation}
X=\begin{cases*}
\mfrac{1}{2}, & \text{if $a=1$} \\
\mfrac{3}{2} & \text{otherwise}
\end{cases*}
\end{equation}
\begin{empheq}[left ={ X = \empheqlbrace}]{alignat*=2}
& \mfrac{1}{2}, &\quad & \text{if $a=1$} \\
& \mfrac{3}{2} & & \text{otherwise}
\end{empheq}
\begin{table}[htbp]
\centering
\caption{Changing the row spacing in the table}
\begin{tabular}{ Sc c c }
\toprule
cell1 & cell2 & cell3 \\
\midrule
cell4 & cell5 & cell6 \\
cell7 & cell8 & cell9 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}