0

Here's my MWE compiled using LuaLaTeX:

\documentclass[oneside,DIV=12]{scrbook}

\usepackage{scrhack}
\usepackage[automark]{scrlayer-scrpage}
\usepackage[english]{babel}
\usepackage[babel]{microtype}
\usepackage{mathtools, amsthm, amssymb}
\usepackage[warnings-off={mathtools-colon,mathtools-overbracket}]{unicode-math}
    \setmathfont{Latin Modern Math}
\usepackage{setspace}\setdisplayskipstretch{}
\usepackage{enumitem}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % List environment settings
\setlist[enumerate]{font={\bfseries}}
\setlist[enumerate,1]{label=\arabic*., labelsep=0.5em}
\setlist[enumerate,2]{label=(\roman*), align=left, leftmargin=3em, labelwidth=2.5em}
    % Resizeable \bullet symbol
\newcommand{\rbullet}[1][.75]{\mathbin{\vcenter{\hbox{\scalebox{#1}{$\bullet$}}}}} % https://tex.stackexchange.com/a/389240/228055
    % Custom amsthm theorem environments
\newtheoremstyle{custom}
  {\topsep}   % ABOVESPACE
  {\topsep}   % BELOWSPACE
  {\normalfont}  % BODYFONT
  {0pt}       % INDENT (empty value is the same as 0pt)
  {\(\rbullet\) \bfseries} % HEADFONT
  { }         % HEADPUNCT
  {\newline} % HEADSPACE
  {\thmnote{#3 }\thmname{#1}} % CUSTOM-HEAD-SPEC
\theoremstyle{custom}
\newtheorem*{problems}{Problems}
\newtheorem*{solutions}{Solutions}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\onehalfspacing\KOMAoptions{DIV=current}

\begin{problems}
\begin{enumerate}
    \item[]
    % No. 01
    \item   Prove the following:
            \begin{enumerate}
                % (i)
                \item \(x^n - y^n = (x - y) (x^{n-1}+ x^{n-2} y + \dots + x y^{n-2} + y^{n-1})\).
                % (ii)
                \item \(x^3 + y^3 = (x + y) (x^2 - xy + y^2)\), (There is a particularly easy way to do this, using \textbf{(iv)}, and it will show you how to find a factorization for \(x^n + y^n\) whenever \(n\) is odd.)
            \end{enumerate}
    % No. 02
    \item What is wrong with the following ``proof''? Let \(x = y\). Then
    \begin{align*}
        x^2 &= xy, \\ 
        x^2 - y^2 &= xy - y^2, \\ 
        (x + y) (x - y) &= y (x - y), \\ 
        x + y &= y, \\ 
        2y &= y, \\ 
        2 &= 1.
    \end{align*}
    % No. 03
    \item   Prove the following:
            \begin{enumerate}
                % (i)
                \item \(\dfrac{a}{b} + \dfrac{c}{d} = \dfrac{ad + bc}{bd}\), if \(b\), \(d \neq 0\).
                % (ii)
                \item \(\left.\dfrac{a}{b} \,\middle/\, \dfrac{c}{d}\right. = \dfrac{ad}{bc}\), if \(b\), \(c\), \(d \neq 0\).  
                % (iii)
                \item If \(b\), \(d \neq 0\), then \(\dfrac{a}{b} = \dfrac{c}{d}\) if and only if \(ad = bc\). Also determine when \(\dfrac{a}{b} = \dfrac{b}{a}\).
            \end{enumerate}
    % No. 04
    \item   Find all numbers \(x\) for which
            \begin{enumerate}
                % (i)
                \item \(\dfrac{1}{x} + \dfrac{1}{1 - x} > 0\).
                % (ii)
                \item \(\dfrac{x - 1}{x + 1} > 0\).
            \end{enumerate}
    % No. 05
    \item   Prove the following:
            \begin{enumerate}
                % (i)
                \item If \(a < b\) and \(c < d\), then \(a + c < b + d\).
                % (ii)
                \item If \(a < b\), then \(-b < -a\).
            \end{enumerate}
    % No. 06
    \item   \begin{enumerate}[label=(\alph*)]
                % (a)
                \item Prove that if \(0 \leq x < y\), then \(x^n < y^n\),\(n = 1, 2, 3, \dots\)
                % (b)
                \item Prove that if \(x < y\) and \(n\) is odd, then \(x^n < y^n\).
            \end{enumerate}
\end{enumerate}
\end{problems}
\end{document}

enter image description here

When using the enumitem package, I am generally fine with the default vertical sep values in lists but I find it to be a bit narrow or tight when there are display style fractions in inline math mode, i.e., \dfracs included in the \items. For example, I find the in-between vertical spacing starting from 3, then 3(i), 3(ii), 3(iii), 4, 4(i), 4(ii), and ending at 5 to be not enough for my personal taste. The rest is fine, though.

My question is: How do I globally adjust/stretch the in-between vertical spacing of items in lists only when they include display style fractions in inline math mode?

Preferably without manually adding options to each and every single enumerate environments that include display style fractions in inline math mode and without globally affecting the vertical spacing and sep values of the other enumerate environments that don't include display style fractions in inline math mode as to not the overstretch the entire document's length. Thank you.

1 Answer 1

1

Here is the way I come up with. Instead of figuring out whether there is \dfrac somewhere in the list and then change the sep, you can locally redefine \dfrac itself, so that it is a bit "taller" that would simulate that additional space.

\documentclass{article}
\usepackage{amsmath}
\usepackage{enumitem}

\setlist[enumerate]{font={\bfseries}}
\setlist[enumerate,1]{label=\arabic*., labelsep=0.5em}
\setlist[enumerate,2]{label=(\roman*), align=left, leftmargin=3em, labelwidth=2.5em}

\makeatletter
\let\enumcopy\enumerate
\let\endenumcopy\endenumerate
\let\olddfrac\dfrac
\renewenvironment{enumerate}{
    \renewcommand{\dfrac}[2]{
        \olddfrac{##1}{##2}
        \ifnum\arabic{\@enumctr}>1
            \rule{0pt}{30pt}
        \fi
    }
    \enumcopy
}{
    \endenumcopy
}
\makeatother

\begin{document}

\begin{enumerate}
\item
    \begin{enumerate}
    \item $\dfrac{1}{2}$
    \item $\dfrac{1}{2}$
    \end{enumerate}
\end{enumerate}


\end{document}

enter image description here

Explanation:

First of all, I make a copy a of enumerate environment by doing

\let\enumcopy\enumerate
\let\endenumcopy\endenumerate

this works because each environment in latex is actually two macros \ENV and endENV. Afterwards you can redefine enumerate using itself.

\renewenvironment{enumerate}{
    \enumcopy
}{
    \endenumcopy
}

Now it's only the matter of placing the redefined \dfrac command inside enumitem environment definition so that it won't affect \dfrac anywhere else at the document.

Again we need a copy of \dfrac to redefine it using itself. The tallness can be increased using \rule{0pt}{<height>} for example.

\let\olddfrac\dfrac
\renewcommand{\dfrac}[2]{\olddfrac{#1}{#2}\rule{0pt}{30pt}}

However, if \dfrac will be placed in the first item of the list, additional space above might not be wanted. In order to fix that you can check if it's not the first item by

\ifnum\arabic{\@enumctr}>1
    <code>
\fi

where \@enumctr is a counter of the current level enumerate environment.

Also note that you have to escape #1 and #2 by adding an extra # if you are using it inside another \renew...


If you set the width of the rule to 1pt for example

\rule{1pt}{30pt}

you will see how exactly it works

enter image description here

1
  • Thank you for your answer! Commented Jun 30, 2022 at 4:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .