Nomencl + KOMA 风格 + 右侧齐平单元 = 错位

Nomencl + KOMA 风格 + 右侧齐平单元 = 错位

我正在格式化我的命名列表。我通过以下方式匹配了文档其余部分的样式这个答案然后尝试通过这个答案。详情如下,提前致谢。


梅威瑟:


\documentclass{scrreprt}
\usepackage{nomencl}
\usepackage{ifthen}
\usepackage{siunitx}

% No extra line space between items
%\setlength{\nomitemsep}{-\parsep}

% Divide nomenclature into subgroups
\newlength\preGroupSkip
\setlength{\preGroupSkip}{3.5ex}
\newlength\postGroupSkip
\setlength{\postGroupSkip}{2.3ex}
\newcommand\groupHeading[1]{%
    \vspace{\preGroupSkip}%
    \item[\usekomafont{sectioning}\usekomafont{section}#1]%
    \hspace*{\leftmargin}\vspace{\postGroupSkip}%
}
\renewcommand{\nomgroup}[1]{%
    \ifthenelse{\equal{#1}{A}}{%
        \groupHeading{Heading of group A}%
    }{}%
    \ifthenelse{\equal{#1}{B}}{%
        \groupHeading{Heading of group B}%
    }{}%
    \ifthenelse{\equal{#1}{C}}{%
        \groupHeading{Heading of group C}%
    }{}%
}
\newcommand{\nomunit}[1]{%
  \renewcommand{\nomentryend}{\hspace*{\fill}[#1]\nolinebreak\hspace*{2cm}\mbox{}}%
}

\makenomenclature

\begin{document}
% Define nomenclature entries
\nomenclature[a]{$m$}{mass \nomunit{$\si{kg}$}}
\nomenclature[b]{$\omega_{\mathrm{m}}$}{mechanical angular frequency \nomunit{$\si{Hz}$}}
\nomenclature[C]{$\omega_{\mathrm{el}}$}{electrical angular frequency \nomunit{$\si{Hz}$}}

\printnomenclature{}
dummy text
\end{document}

导致: 对齐问题

答案1

插入\par之前\vspace{\preGroupSkip}

\documentclass{scrreprt}
\usepackage{nomencl}
\usepackage{ifthen}
\usepackage{siunitx}

% No extra line space between items
%\setlength{\nomitemsep}{-\parsep}

% Divide nomenclature into subgroups
\newlength\preGroupSkip
\setlength{\preGroupSkip}{3.5ex}
\newlength\postGroupSkip
\setlength{\postGroupSkip}{2.3ex}
\newcommand\groupHeading[1]{%
    \par% <- added
    \vspace{\preGroupSkip}%
    \item[\usekomafont{sectioning}\usekomafont{section}#1]%
    \hspace*{\leftmargin}\vspace{\postGroupSkip}%
}
\renewcommand{\nomgroup}[1]{%
    \ifthenelse{\equal{#1}{A}}{%
        \groupHeading{Heading of group A}%
    }{}%
    \ifthenelse{\equal{#1}{B}}{%
        \groupHeading{Heading of group B}%
    }{}%
    \ifthenelse{\equal{#1}{C}}{%
        \groupHeading{Heading of group C}%
    }{}%
}
\newcommand{\nomunit}[1]{%
  \renewcommand{\nomentryend}{\hspace*{\fill}[#1]\nolinebreak\hspace*{2cm}\mbox{}}%
}

\makenomenclature

\begin{document}
% Define nomenclature entries
\nomenclature[a]{$m$}{mass \nomunit{$\si{kg}$}}
\nomenclature[b]{$\omega_{\mathrm{m}}$}{mechanical angular frequency \nomunit{$\si{Hz}$}}
\nomenclature[C]{$\omega_{\mathrm{el}}$}{electrical angular frequency \nomunit{$\si{Hz}$}}

\printnomenclature{}
dummy text
\end{document}

在此处输入图片描述


解释:

文件内容nls

\begin{thenomenclature} 
\nomgroup{A}
  \item [{$m$}]\begingroup mass \nomunit{$\si{kg}$}\nomeqref {0.0}\nompageref{1}
\nomgroup{B}
  \item [{$\omega_{\mathrm{m}}$}]\begingroup mechanical angular frequency \nomunit{$\si{Hz}$}\nomeqref {0.0}\nompageref{1}
\nomgroup{C}
  \item [{$\omega_{\mathrm{el}}$}]\begingroup electrical angular frequency \nomunit{$\si{Hz}$}\nomeqref {0.0}\nompageref{1}

\end{thenomenclature}

因此该问题可以通过以下 MWE 来模拟:

\documentclass{scrreprt}
\usepackage{showframe}
\begin{document}
\begin{enumerate}
  \item an entry \hfill first\label{first}
  \item an entry \hfill foo\label{foo}
  \vspace{10pt}
  \item an entry \hfill bar\label{bar}
\end{enumerate}
\end{document}

在此处输入图片描述

\vspace在当前行的末尾插入垂直空格。因此在此之前有一个虚假空格\vspace。要删除这个虚假空格,您可以注释掉上一行的末尾

\documentclass{scrreprt}
\usepackage{showframe}
\begin{document}
\begin{enumerate}
  \item an entry \hfill first\label{first}
  \item an entry \hfill foo\label{foo}% <- removes the spurious space
  \vspace{10pt}
  \item an entry \hfill bar\label{bar}
\end{enumerate}
\end{document}

或者你可以使用\par来完成上一段:

\documentclass{scrreprt}
\usepackage{showframe}
\begin{document}
\begin{enumerate}
  \item an entry \hfill first\label{first}
  \item an entry \hfill foo\label{foo}
  \par
  \vspace{10pt}
  \item an entry \hfill bar\label{bar}
\end{enumerate}
\end{document}

在此处输入图片描述

相关内容