用語集名の手動改行

用語集名の手動改行

ここで、独自の用語集スタイルを定義する方法を見つけました:

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

nameの -fieldで手動で行を折り返すにはどうすればいいですか\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改行として etc. を追加しようとしましたが、成功しませんでした。

\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パッケージでは という 2 番目の列の長さが定義されてい\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}

これにより、次のようになります。

用語集の画像

関連情報