更改 glossarystyle 树以删除缩进并设置固定 itemwidth

更改 glossarystyle 树以删除缩进并设置固定 itemwidth

我正在寻找一种方法来改变我的词汇表树的外观,并且正在努力找出有哪些选择。我想要一个可以删除子条目缩进并且条目名称具有固定宽度的树。我目前的情况是这样的

\documentclass[openany]{memoir}
\usepackage[abbreviations,nomain,section=section,nonumberlist,style=tree]{glossaries-extra}
    \makeglossaries
    \setabbreviationstyle[archive]{long-short-sc}
    \renewcommand{\glsnamefont}[1]{\textsc{\mdseries #1}}
\begin{document}    
    \newacronym{AIP}{aip}{Niels Bohr Library \& Archives, American Institute of Physics}
    \newacronym[category=archive, parent=AIP]{AIP/EH}{aip/eh}{Ejnar Hertzsprung correspondence [microform], 1902-1967, MI30013}
    \newacronym[category=archive, parent=AIP]{AIP/FS}{aip/fs}{Frank Schlesinger Yale corrspondence [microform], MI72}
    \newacronym[category=archive, parent=AIP]{AIP/OH}{aip/oh}{Oral Histories. www.aip.org/history-programs/niels-bohr-library/oral-histories}
    \newacronym[category=archive, parent=AIP]{AIP/OS}{aip/oh}{Otto Struve selected correspondence [microform], MI78}

    \newacronym[category=archive]{HUA}{hua}{Harvard University Archives}
    \newacronym[category=archive, parent=HUA]{HUA/BB}{hua/bb}{Papers of Bart J Bok, 1930-1957, HUG 4223}
    \newacronym[category=archive, parent=HUA]{HUA/DM}{hua/dm}{ Papers of Donald Howard Menzel, HUG 4567}
    \newacronym[category=archive, parent=HUA]{HUA/HS}{hua/hs}{ Papers of Harlow Shapley, HUG 4773}

    \newacronym[category=archive]{LU}{lu}{ Leiden University Library, Special Collections}
    \newacronym[category=archive, parent=LU]{LU/ESB}{lu/esb}{Leiden Observatory Archives, directorate E.F. van de Sande Bakhuyzen}
    \newacronym[category=archive, parent=LU]{LU/JO}{lu/jo}{ Papers of Jan Hendrik Oort}
    \newacronym[category=archive, parent=LU]{LU/WdS}{{lu/w\textnormal{d}s}}{ Leiden Observatory Archives, directorate Willem de Sitter}

\glsaddall
\printglossary
\end{document}

这使 在此处输入图片描述 但我希望它看起来像这样: 在此处输入图片描述 我现在不确定很多美学上的改变是否可行,它们并不都是必要的,但我希望它们尽可能接近。

更新

alttree通过切换到、使用\glssetwidest\addtolength\glstreeindent\parindent从文件第 252 行中删除,我设法获得了我想要的东西glossary-tree.sty。有没有更强大的方法可以做同样的事情而不必弄乱文件.sty

答案1

如果有人好奇或正在寻找答案,我通过创建包含自定义词汇表样式的语言环境包解决了我的问题。这是基于alttree但经过调整的,以便它能完成我想要它做的事情。

\ProvidesPackage{glossary-mytree}
\providecommand{\indexspace}{%
  \par \vskip 10\p@ \@plus 5\p@ \@minus 3\p@ \relax
}
\newglossarystyle{mytree}{%
  \renewenvironment{theglossary}%
    {\def\@gls@prevlevel{-1}%
     \mbox{}\par}%
    {\par}%
  \renewcommand*{\glossaryheader}{}%
  \renewcommand*{\glsgroupheading}[1]{}%
  \renewcommand{\glossentry}[2]{%
   \ifnum\@gls@prevlevel=0\relax
   \else
       \settowidth{\glstreeindent}{\glstreenamefmt{\@glswidestname\space}}%
   \fi
    \vspace{\baselineskip}
    \hangindent\glstreeindent
    \parindent\glstreeindent
    \makebox[0pt][r]{\glstreenamebox{\glstreeindent}{%
       \glsentryitem{##1}\glstreenamefmt{\glstarget{##1}{\glossentryname{##1}}}}}%
    \ifglshassymbol{##1}{(\glossentrysymbol{##1})\space}{}%
    \textbf{\glossentrydesc{##1}}\glspostdescription \space ##2\par
    \def\@gls@prevlevel{0}%
  }%
  \renewcommand{\subglossentry}[3]{%
    \ifnum##1=0\relax
      \glssubentryitem{##2}%
    \fi
    \ifnum\@gls@prevlevel=##1\relax
    \else
      \@ifundefined{@glswidestname\romannumeral##1}{%
        \settowidth{\gls@tmplen}{\glstreenamefmt{\@glswidestname\space}}}{%
        \settowidth{\gls@tmplen}{\glstreenamefmt{%
           \csname @glswidestname\romannumeral##1\endcsname\space}}}%
      \ifnum\@gls@prevlevel<##1\relax
         \setlength\glstreeindent\gls@tmplen
         \parindent\glstreeindent
      \else
         \@ifundefined{@glswidestname\romannumeral\@gls@prevlevel}{%
           \settowidth{\glstreeindent}{\glstreenamefmt{%
              \@glswidestname\space}}}{%
           \settowidth{\glstreeindent}{\glstreenamefmt{%
              \csname @glswidestname\romannumeral\@gls@prevlevel
                 \endcsname\space}}}%
         \addtolength\parindent{-\glstreeindent}%
         \setlength\glstreeindent\parindent
      \fi
    \fi
    \hangindent\glstreeindent
    \makebox[0pt][r]{\glstreenamebox{\gls@tmplen}{%
      \glstreenamefmt{\glstarget{##2}{\normalfont{\glossentryname{##2}}}}}}%
    \ifglshassymbol{##2}{(\glossentrysymbol{##2})\space}{}%
    \glossentrydesc{##2}\glspostdescription\space ##3\par
    \def\@gls@prevlevel{##1}%
  }%
  \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else\indexspace\fi}%
}
\endinput

梅威瑟:

\documentclass[openany]{memoir}
\usepackage[abbreviations,nomain,section=section,nonumberlist,nogroupskip]{glossaries-extra}
\usepackage{glossary-mytree}
    \makeglossaries
    \setabbreviationstyle[archive]{short}
    \glssetwidest{MMMMN}
    \usepackage{libertine}

\setglossarystyle{mytree}
\begin{document}    
    \newacronym{AIP}{AIP}{Niels Bohr Library \& Archives, American Institute of Physics}
    \newacronym[category=archive, parent=AIP]{AIP/EH}{AIP/EH}{Ejnar Hertzsprung correspondence [microform], 1902-1967, MI30013}
    \newacronym[category=archive, parent=AIP]{AIP/FS}{AIP/FS}{Frank Schlesinger Yale corrspondence [microform], MI72}
    \newacronym[category=archive, parent=AIP]{AIP/OH}{AIP/OH}{Oral Histories. www.aip.org/history-programs/niels-bohr-library/oral-histories}
    \newacronym[category=archive, parent=AIP]{AIP/OS}{AIP/OH}{Otto Struve selected correspondence [microform], MI78}

    \newacronym[category=archive]{HUA}{HUA}{Harvard University Archives}
    \newacronym[category=archive, parent=HUA]{HUA/BB}{HUA/BB}{Papers of Bart J Bok, 1930-1957, HUG 4223}
    \newacronym[category=archive, parent=HUA]{HUA/DM}{HUA/DM}{ Papers of Donald Howard Menzel, HUG 4567}
    \newacronym[category=archive, parent=HUA]{HUA/HS}{HUA/HS}{ Papers of Harlow Shapley, HUG 4773}

    \newacronym[category=archive]{LU}{LU}{ Leiden University Library, Special Collections}
    \newacronym[category=archive, parent=LU]{LU/ESB}{LU/ESB}{Leiden Observatory Archives, directorate E.F. van de Sande Bakhuyzen}
    \newacronym[category=archive, parent=LU]{LU/JO}{LU/JO}{ Papers of Jan Hendrik Oort}
    \newacronym[category=archive, parent=LU]{LU/WdS}{{LU/WdS}}{ Leiden Observatory Archives, directorate Willem de Sitter}

\glsaddall 
\printglossary
\end{document}

结果: 在此处输入图片描述

相关内容