在对齐环境中枚举

在对齐环境中枚举

我正在尝试重新格式化文档,并遇到了一个很长的列表。以下是其中一些项目:

\begin{enumerate}[(a)]
    \item \(\displaystyle \pdv{f}{x}=-\frac{y}{x^{2}+y^{2}} \quad  \pdv{f}{y}=\frac{x}{x^{2}+y^{2}} \) 
    \item \(\displaystyle \pdv{f}{x}=y x^{y-1} \quad  \pdv{f}{y}=x^{y} \ln x
    \item \(\displaystyle \pdv{f}{x}=\frac{1}{\sqrt{y}} \cot \left(\frac{x+a}{\sqrt{y}}\right) \quad  \pdv{f}{y}=-\frac{(x+a)}{2 y \sqrt{y}} \cot \left(\frac{x+a}{\sqrt{y}}\right) \)
\end{enumerate}

不幸的是它很混乱:

旧代码

我想在 itemize 环境中对齐 2 个“自然”列。下面的代码或多或少实现了我想要的功能:

\newcounter{myrownumbers}
\newcommand\myrownumber{\stepcounter{myrownumbers}\makebox[13.5pt][s]{\text{(\alph{myrownumbers})}}\hspace{\tabcolsep}}
\begin{flalign*}
       &\myrownumber \pdv{f}{x}=-\frac{y}{x^{2}+y^{2}} & &  \pdv{f}{y}=\frac{x}{x^{2}+y^{2}} & \\
       &\myrownumber \pdv{f}{x}=y x^{y-1} & &  \pdv{f}{y}=x^{y} \ln x & \\
       &\myrownumber \pdv{f}{x}=\frac{1}{\sqrt{y}} \cot \left(\frac{x+a}{\sqrt{y} \right) & &  \pdv{f}{y}=-\frac{(x+a)}{2 y \sqrt{y}} \cot \left(\frac{x+a}{\sqrt{y}}\right) &
\end{flalign*}

被黑代码

然而,即使忽略丑陋的代码,这也不是一个令人满意的解决方案。因为我真的想模仿itemize,所以我添加了,hbox这样对齐方式就不会依赖于标签的宽度,但这会导致很多overfull hbox警告。

我也尝试使用tabular和的解决方案array,但得到的标签看起来像itemize

梅威瑟:

\documentclass{book}
\usepackage{amsmath}
\usepackage{enumerate}
\usepackage{derivative}

\begin{document}
    Old code:
    \begin{enumerate}[(a)]
        \item \(\displaystyle \pdv{f}{x}=-\frac{y}{x^{2}+y^{2}} \quad  \pdv{f}{y}=\frac{x}{x^{2}+y^{2}} \) 
        \item \(\displaystyle \pdv{f}{x}=y x^{y-1} \quad  \pdv{f}{y}=x^{y} \ln x \)
        \item \(\displaystyle \pdv{f}{x}=\frac{1}{\sqrt{y}} \cot \left(\frac{x+a}{\sqrt{y}}\right) \quad  \pdv{f}{y}=-\frac{(x+a)}{2 y \sqrt{y}} \cot \left(\frac{x+a}{\sqrt{y}}\right) \)
    \end{enumerate}
    \newcounter{myrownumbers}
    \newcommand\myrownumber{\stepcounter{myrownumbers}\makebox[13.5pt][s]{\text{(\alph{myrownumbers})}}\hspace{\tabcolsep}}
    I want something like this:
    \begin{flalign*}
           &\myrownumber \pdv{f}{x}=-\frac{y}{x^{2}+y^{2}} & &  \pdv{f}{y}=\frac{x}{x^{2}+y^{2}} & \\
           &\myrownumber \pdv{f}{x}=y x^{y-1} & &  \pdv{f}{y}=x^{y} \ln x & \\
           &\myrownumber \pdv{f}{x}=\frac{1}{\sqrt{y}} \cot \left(\frac{x+a}{\sqrt{y}}\right) & &  \pdv{f}{y}=-\frac{(x+a)}{2 y \sqrt{y}} \cot \left(\frac{x+a}{\sqrt{y}}\right) &
    \end{flalign*}
\end{document}

答案1

代码基于enumerate

\documentclass{book}
\usepackage{amsmath}
\usepackage{enumitem}
\usepackage{derivative}


\begin{document}
\begin{enumerate}[label=\alph*),before={\everymath={\displaystyle}}]
  \item \makebox[0.35\linewidth][l]{\(\pdv{f}{x} = -\frac{y}{x^{2}+y^{2}}\)}
    \(\pdv{f}{y} = \frac{x}{x^{2} + y^{2}}\)
  \item \makebox[0.35\linewidth][l]{\(\pdv{f}{x} = y x^{y-1}\)}
    \(\pdv{f}{y}=x^{y} \ln x\)
  \item \makebox[0.35\linewidth][l]{\(\pdv{f}{x} = \frac{1}{\sqrt{y}} \cot \left(\frac{x+a}{\sqrt{y}}\right)\)}
    \(\pdv{f}{y}=-\frac{(x+a)}{2 y \sqrt{y}} \cot \left(\frac{x+a}{\sqrt{y}}\right)\)
\end{enumerate}
\end{document}

在此处输入图片描述

答案2

您可以使用任务包:

\documentclass{book}
\usepackage{amsmath}
\usepackage{enumerate}
\usepackage{derivative}
\usepackage{tasks}
\settasks{label=(\alph*),label-width=1.4em}% if you want the sames labels as enumerate 

\begin{document}
    \begin{tasks}(2)
        \task \(\displaystyle \pdv{f}{x}=-\frac{y}{x^{2}+y^{2}}\) \task[] \(\displaystyle \pdv{f}{y}=\frac{x}{x^{2}+y^{2}} \) 
        \task \(\displaystyle \pdv{f}{x}=y x^{y-1} \) \task[] \( \displaystyle \pdv{f}{y}=x^{y} \ln x \)
        \task \(\displaystyle \pdv{f}{x}=\frac{1}{\sqrt{y}} \cot \left(\frac{x+a}{\sqrt{y}}\right) \) \task[] \(\displaystyle   \pdv{f}{y}=-\frac{(x+a)}{2 y \sqrt{y}} \cot \left(\frac{x+a}{\sqrt{y}}\right) \)
    \end{tasks}
\end{document}

相关内容