術語表名稱中的手動換行符

術語表名稱中的手動換行符

我在這裡找到了一種定義我自己的術語表風格的方法:

\newglossarystyle{superglossarystyle}
{
    \setglossarystyle{super}
    \renewenvironment{theglossary}
    {
        \tablehead{}
        \tabletail{}
        \begin{supertabular}{rp{\glsdescwidth}}
    }
    {
        \end{supertabular}
    }
}
%
\setglossarystyle{superglossarystyle}

如何在name- 字段中手動換行\newglossaryentry

現在看起來如何:

ParameterA,ParameterB  This is the description of ParameterA and ParameterB,
                       that is long and automatically wraps.

           ParameterC  This is the description of ParameterC, that is long
                       and automatically wraps.

它應該是什麼樣子:

ParameterA,
ParameterB   This is the description of ParameterA and ParameterB,
             that is long and automatically wraps.

ParameterC   This is the description of ParameterC, that is long
             and automatically wraps.

我嘗試添加\\,\linebreak,\tabbreak等作為換行符,但沒有成功。

\documentclass[pdftex,a4paper,oneside,12pt,halfparskip]{scrbook}
\usepackage[]{amsmath,amssymb}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[a4paper,top=3.6cm,bottom=3.6cm,left=3.6cm,right=3.6cm]{geometry}
\usepackage[]{glossaries}

\newglossarystyle{superglossarystyle}
{
    \setglossarystyle{super}
    \renewenvironment{theglossary}
    {
        \tablehead{}
        \tabletail{}
        \begin{supertabular}{cp{\glsdescwidth}}
    }
    {
        \end{supertabular}
    }
}

\setglossarystyle{superglossarystyle}
\makeglossaries

\newglossaryentry{pab}
{
    name        = {$\boldsymbol{ParameterA},\boldsymbol{ParameterB}$} ,
    description = {This is the description of ParameterA and ParameterB, that is long and automatically wraps} ,
}

\newglossaryentry{pc}
{
    name        = {$\boldsymbol{ParameterC}$} ,
    description = {This is the description of ParameterC, that is long and automatically wraps.} ,
}

\begin{document}

\glsaddallunused\printglossaries

\end{document}

答案1

標準列說明符是l, r,cp{長度}。您可以使用以下命令定義新的列類型array包,但我認為在這種情況下不需要這樣做,因為您可以使用 調整段落對齊方式\raggedleft。在定義新的術語表樣式時,考慮該樣式的簡化版本會有所幫助。在基本層面上,樣式需要採用以下形式:

\documentclass{article}

\begin{document}
\begin{tabular}{p{2cm}p{4cm}}
\raggedleft A. & some text\\
\raggedleft AA. & some more text\\
\raggedleft AAA. & some more text
\end{tabular}

\end{document}

它有一個右對齊的段落樣式第一列。

第一列右對齊的影像

現在測試如果ParameterA,ParameterB添加會發生什麼:

\documentclass{article}

\begin{document}
\begin{tabular}{p{2cm}p{4cm}}
\raggedleft A. & some text\\
\raggedleft AA. & some more text\\
\raggedleft AAA. & some more text\\
\raggedleft ParameterA,ParameterB & some text
\end{tabular}

\end{document}

這沒有換行,因為 TeX 無法插入換行符,所以結果相當難看。

線條過滿的圖像

相反,您需要為 TeX 提供一些範圍來在逗號處換行:

\documentclass{article}

\newcommand{\comma}{,\penalty \exhyphenpenalty}

\begin{document}

\begin{tabular}{p{2cm}p{4cm}}
\raggedleft A. & some text\\
\raggedleft AA. & some more text\\
\raggedleft ParameterA\comma ParameterB & some text
\end{tabular}

\end{document}

TeX 現在可以打破這條線:

逗號後換行的圖片

2cm在這裡,我使用和硬編碼了列寬4cm,但glossaries套件定義了名為 的第二列的長度\glsdescwidth。您可以定義用於第一列的另一個長度:

\newlength\glsnamewidth

您需要根據您的文件設定該值。例如:

\setlength{\glsnamewidth}{3cm}

或者

\setlength{\glsnamewidth}{0.3\hsize}

新的術語表樣式可以定義為:

\newglossarystyle{superglossarystyle}
{%
  \setglossarystyle{super}%
  \renewenvironment{theglossary}%
  {%
      \tablehead{}%
      \tabletail{}%
      \begin{supertabular}{p{\glsnamewidth}p{\glsdescwidth}}%
  }%
  {%
      \end{supertabular}%
  }%
  \renewcommand{\glossentry}[2]{%
    \raggedleft
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \glossentrydesc{##1}\glspostdescription\space ##2\tabularnewline
  }%
}

完整的例子是:

\documentclass[pdftex,a4paper,oneside,12pt,halfparskip]{scrbook}
\usepackage[]{amsmath,amssymb}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[a4paper,top=3.6cm,bottom=3.6cm,left=3.6cm,right=3.6cm]{geometry}
\usepackage[]{glossaries}

\newcommand{\comma}{,\penalty \exhyphenpenalty}
\newlength\glsnamewidth
\setlength{\glsnamewidth}{0.3\hsize}

\newglossarystyle{superglossarystyle}
{%
  \setglossarystyle{super}%
  \renewenvironment{theglossary}%
  {%
      \tablehead{}%
      \tabletail{}%
      \begin{supertabular}{p{\glsnamewidth}p{\glsdescwidth}}%
  }%
  {%
      \end{supertabular}%
  }%
  \renewcommand{\glossentry}[2]{%
    \raggedleft
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \glossentrydesc{##1}\glspostdescription\space ##2\tabularnewline
  }%
}

\setglossarystyle{superglossarystyle}
\makeglossaries

\newglossaryentry{pab}
{
    name        =
{$\boldsymbol{ParameterA}\comma\boldsymbol{ParameterB}$} ,
    description = {This is the description of ParameterA and
ParameterB, that is long and automatically wraps} ,
}

\newglossaryentry{pc}
{
    name        = {$\boldsymbol{ParameterC}$} ,
    description = {This is the description of ParameterC, that is
long and automatically wraps.} ,
}

\begin{document}

\glsaddallunused\printglossaries

\end{document}

其產生:

詞彙表圖片

相關內容