我想使用案例环境,但是当我的 baselinestretch 为 2 时,它的垂直间距太大了(而我注意到使用 baselinestretch 为 1 的垂直间距看起来很完美)。如何在不更改 baselinestretch 的情况下局部减少案例环境的垂直间距?
我的代码是这样的
\documentclass[12pt,reqno]{article}
\renewcommand{\baselinestretch}{2}
\usepackage[utf8]{inputenc}
\usepackage[left=1.25in, right=1.25in, top=1.25in]{geometry}
\usepackage{amssymb, amsmath, amsfonts}
\setlength{\parindent}{2em}
\setlength{\textwidth}{6 in}
\setlength{\textheight}{8.5in}
\newcommand{\ben}{\begin{equation*}}
\newcommand{\een}{\end{equation*}}
\begin{document}
\noindent\textbf{2.} Suppose that $f,g: \mathbb{R}\rightarrow\mathbb{R}$ are such that $f$ is differentiable at $a$ but $g$ is not. Prove or disprove that that $f+g$ is differentiable at $a$.
\renewcommand{\labelenumi}{}
\begin{enumerate}
\item We will show that $f+g$ is not differentiable at $a$. As a counterexample, define
\ben f(x) = \begin{cases} 0, & x<0 \\ 1, & x\geq 0 \end{cases} \een
and
\end{enumerate}
\end{document}
这让我
答案1
我假设您希望\baselinestretch
在处于 display-math 环境中时将其重置为 1。请注意,cases
环境可以出现在 display-math 和 inline-math 设置中。当然,可以说前者比后者更常见。
如果这个假设是正确的,我建议你使用包setspace
,这样你就不必直接操作低级宏\baselinestretch
。相反,插入指令
\everydisplay=\expandafter{\the\everydisplay\setstretch{1}}
在序言的某处,后正在加载setspace
包。
另外,我建议你更换
$f,g: \mathbb{R}\rightarrow\mathbb{R}$
和
$f,g\colon \mathbb{R}\rightarrow\mathbb{R}$
即替换:
为\colon
。
\documentclass[12pt,reqno]{article}
%\renewcommand{\baselinestretch}{2}
\usepackage[nodisplayskipstretch]{setspace} % for "\setstretch" macro
\setstretch{2.0}
\everydisplay=\expandafter{\the\everydisplay\setstretch{1}} % <-- new
\usepackage[utf8]{inputenc}
\usepackage[margin=1.25in]{geometry}
%\setlength{\textwidth}{6 in}
%\setlength{\textheight}{8.5in}
\usepackage{amssymb, amsmath}
\setlength{\parindent}{2em}
\renewcommand{\labelenumi}{}
\begin{document}
\noindent
\textbf{2.} Suppose that $f,g\colon \mathbb{R}\to\mathbb{R}$ are such that $f$ is differentiable at~$a$ but $g$ is not. Prove or disprove that $f+g$ is differentiable at~$a$.
\begin{enumerate} %\singlespacing
\item We will show that $f+g$ is not differentiable at $a$. As a counterexample, define
\[
f(x) =
\begin{cases}
0, & x<0 \\
1, & x\geq 0
\end{cases}
\]
and \dots
\end{enumerate}
\end{document}
答案2
最好使用setspace
而不是原始的\baselinestretch
。
不仅cases
排版方式不太好,而且数组和矩阵也是如此。
\documentclass[12pt,reqno]{article}
\usepackage[utf8]{inputenc}
\usepackage[left=1.25in, right=1.25in, top=1.25in]{geometry}
\usepackage{amssymb, amsmath, amsfonts}
\usepackage{etoolbox}
\usepackage{setspace}
\setstretch{2}
% set the standard \arraystretch to get back to normal
\renewcommand{\arraystretch}{0.5}
% cases uses 1.2, so we need to halve it
\makeatletter
\patchcmd{\env@cases}{1.2}{0.6}{}{}
\makeatother
\begin{document}
\noindent\textbf{2.} Suppose that $f,g: \mathbb{R}\rightarrow\mathbb{R}$ are
such that $f$ is differentiable at $a$ but $g$ is not. Prove or disprove that
$f+g$ is differentiable at $a$.
\begin{enumerate}
\item We will show that $f+g$ is not differentiable at $a$. As a counterexample, define
\begin{equation*}
f(x) = \begin{cases} 0, & x<0 \\ 1, & x\geq 0 \end{cases}
\end{equation*}
\end{enumerate}
\end{document}
\textheight
注意:我删除了和的设置\textwidth
,它们要么无用,要么与 的设置相矛盾geometry
。
另外\ben
,\een
我们不推荐这样做:您在击键方面获得的收益很小,而在清晰度方面却损失很大。