1

Hi everyone I'm not very good at using latex yet, but I am figuring it out, so my apologies in advance if this is something super basic.

I am trying to create an additional single page after my glossary for standard amino acid codes (needs to be listed in toc as well), but I don't know how to get a third column beside the three letter code, which would show the symbol (the one letter code) beside the three letter code. I set up a custom style (and by set up I mean copied this code from somewhere that I now cannot find) that modifies the long glossary style, and I played around a bunch, but I couldn't get the "custom" style to show a third column listing the "symbols", the one letter code.

Here is a MWE.

\documentclass{report}

\usepackage[nogroupskip,toc]{glossaries-extra} \renewcommand{\glsnamefont}[1]{\textbf{#1}}

\newglossarystyle{custom}{ \setglossarystyle{long} \renewenvironment{theglossary} {\begin{longtable}[l]{@{}p{\dimexpr 3.5cm-\tabcolsep}p{0.8\hsize}}} {\end{longtable}} } \setglossarystyle{custom}

\newglossaryentry{ala}{name={Alanine},symbol={A},description={Ala}} \newglossaryentry{arg}{name={Arginine},symbol={R},description={Arg}}

\begin{document}

\printunsrtglossary[title=Standard amino acid codes]

\end{document}

I realize that maybe "long" isn't the right glossary style to do this, but after trying for so long (no pun intended) I'm kind of giving up and hoping that someone has a better solution.

The finished product would look like something this. Example

If I'm doing this completely wrong and somebody has a better way I am all ears! I am a biochemist, and trying to use latex to write my thesis since word is awful at just about anything that is more complicated than a cooking recipe, and I rather struggle through latex than use word.

jfang5
  • 49

1 Answers1

0

The long3col style allows to do what you want. (see long3col)

Notes.

(1) Space between groups can be eliminated uncommenting the line \renewcommand*{\glsgroupskip}{}% OPTIONAL .. <<< (now commented)

(2) To add table headers uncomment the line \bfseries Name & \bfseries Description & \bfseries Symbol \tabularnewline[5pt] % OPTIONAL header <<<<<<<<<< and change \setlength{\glsdescwidth}{0.12\textwidth} % to \setlength{\glsdescwidth}{0.2\textwidth} %

zzz

\documentclass[a4paper,10pt]{article}
\usepackage{glossaries}

\makeglossaries

\newglossaryentry{ala}{% name={Alanine},% symbol={A},% description={Ala}% } \newglossaryentry{arg}{% name={Arginine},% symbol={R},% description={Arg}% }

\newglossaryentry{gly}{% name={Glycine},% symbol={G},% description={Gly}% }

\newglossaryentry{val}{% name={Valine},% symbol={V},% description={Val}% }

\newlength{\glsnamewidth} \setlength{\glsnamewidth}{0.2\textwidth} \setlength{\glsdescwidth}{0.12\textwidth} % change to 0.2\textwidth to use table headers <<<<<<<<<<<<

%% See https://tex.stackexchange.com/a/281772/161015 \newglossarystyle{AMINOstyle}{% glossary in a longtable environment \sffamily \setlength\LTleft{-5pt} % left margin of long table \setglossarystyle{long3col}% based it on the long3col style \renewenvironment{theglossary}% {\begin{longtable}{p{\glsnamewidth}p{\glsdescwidth}c}}% {\end{longtable}}% \renewcommand{\glossaryheader}{% %\bfseries Name & \bfseries Description & \bfseries Symbol \tabularnewline[5pt] % OPTIONAL header <<<<<<<<<<<<< \endhead}% \renewcommand{\glossentry}[2]{% \glsentryitem{##1}\glstarget{##1}{\bfseries\glossentryname{##1}} % Name &\glossentrydesc{##1} % Description & \glsentrysymbol{##1} % Symbol \tabularnewline }% %\renewcommand{\glsgroupskip}{}% OPTIONAL uncomment to eliminate the space between groups }

\begin{document}

\glsaddall

\glossarystyle{AMINOstyle}

\printglossary[title=\normalfont \sffamily Standard amino acid codes]

\end{document}

Simon Dispa
  • 39,141
  • Thank you so much! The code you provided was very helpful, and I see the benefits of the way you lined the code up to comment and explain it. I will try and do that in the future as well. I upvoted your answer but I think my account is too new. Thank you again! – jfang5 Jun 12 '21 at 00:13