1

I am using this solution by Bernard to have equations in display mode appear single-spaced in a double-spaced document. How can I achieve a similar result for inline math?

\documentclass{article}

\usepackage{lipsum} \usepackage{amsmath} \usepackage{physics} \usepackage{fontspec} \usepackage[doublespacing,nodisplayskipstretch]{setspace}

\usepackage{etoolbox} \BeforeBeginEnvironment{align}{\begin{singlespace}\vspace{-\baselineskip}} \AfterEndEnvironment{align*}{\end{singlespace}\noindent\ignorespaces}

\begin{document}

\lipsum[2] \begin{align} Abc = DEF \ DEF = Abc \end{align*} \lipsum[2]

Inline math: $\mqty(x\y)$

\end{document}

1 Answers1

1

It's better to set \jot to a negative dimension. Next, you can set \arraystretch to the reciprocal of \baselinestretch, which will affect array based objects.

\documentclass{article}

\usepackage{amsmath} \usepackage{physics} \usepackage[ doublespacing, nodisplayskipstretch ]{setspace}

\usepackage{lipsum}

\setlength{\jot}{-4pt} \renewcommand{\arraystretch}{0.6}

\begin{document}

\lipsum[2] \begin{align} Abc = DEF \ DEF = Abc \end{align*} \lipsum[2]

Inline math: $\mqty(x\y)$

\end{document}

Explanation: amsmath adds \jot to the interline spacing in its alignment environments.

enter image description here

Not that I endorse using physics; actually I recommend not using it.

If you want to also fix cases, load etoolbox and, in the document preamble, say

\makeatletter
\patchcmd{\env@cases}{1.2}{0.72}{}{}
\makeatother

enter image description here

Why 0.72? Because \env@cases does \renewcommand{\arraystretch}{1.2}, but we actually want it to be 1.2 times 0.6, which is the reciprocal of 1.667, the value of \baselinestretch for doublespacing.

If \onehalfspacing is used, it corresponds to a value 1.25 of \baselinestretch and the reciprocal to use is 0.8. For cases you need 0.96 instead of 0.72.

egreg
  • 1,121,712
  • 1
    Thanks!, How did you determine the -4pt and 0.6 numbers? should these change if I am actually using onehalfspacing and different font size? – user1830663 May 05 '23 at 22:03
  • 1
    Also, I think your solution has drawbacks when it comes to display math compared to Bernard's from the post I linked. For example, using \begin{cases} \end{cases} inside a \begin{equation} gives rise to double-spacing with your solution but not with Bernard's. – user1830663 May 05 '23 at 22:09
  • @user1830663 You also need to fix cases. Just don't worry: double spacing completely ruins a document, so why bother? Anyway, it's Bernard's solution that has drawbacks. I'll add the fix for cases. – egreg May 05 '23 at 22:13
  • 1
    Thesis style requirements... no choice – user1830663 May 05 '23 at 22:16
  • @user1830663 Try telling them we're in the 21st century. – egreg May 05 '23 at 22:21
  • 1
    Thanks for the help. Why -4pt in \setlength{\jot}{-4pt} ? – user1830663 May 05 '23 at 22:25
  • @user1830663 Visual determination. – egreg May 06 '23 at 08:52