テキスト、数式、表の間隔を管理する

テキスト、数式、表の間隔を管理する

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} 

ここに画像の説明を入力してください

関連情報