[Tex/LaTex] How to print the glossary into a table

glossariestables

I would like to rearrange words from the environment glossary into a table. I mean I would like to print them into a table. I would like to make three columns. In the first column I would like to have the content of the name, \textbf{…}; in the second column I would like to have the text in the environment tipa, [\textipa{…}] and in the third column I would like to have the rest of text, \textit{…}. The structure of words is under the source code.

Thanks for help.

\documentclass[10pt,a6paper]{book}
%46paper
\usepackage[utf8]{inputenc}
\usepackage[main=english, slovak]{babel}
\usepackage[cm]{fullpage}
\usepackage[a6paper, top=15mm, left=10mm, right=10mm, bottom=10mm,foot=5mm,marginparsep=0mm]{geometry}
\usepackage{tipa}
\usepackage{lscape}
\usepackage{listings}
\usepackage{glossaries}

\makeglossaries
\input{txt.txt}

\begin{document}
\catcode`\-=12
\sloppy

{\large
\printglossaries
\glsaddall
}

\end{document}

% structure of words in file txt.txt
%-----------------------------------
\newglossaryentry{accelerator}
{
  name={\textbf{accelerator}},
  description={ [\textipa{@k\textprimstress sel.@.reI.t@\super r}]  \textit{the meaning} }
}

Best Answer

I recommend you put the IPA part in a separate field, for example in the symbol field. This makes it easier to layout the two parts separately. For example:

\documentclass{book}

\usepackage{tipa}
\usepackage{longtable}
\usepackage{glossaries}

\makeglossaries

\newglossarystyle{ipa}
{%
  % longtable with three columns:
  \renewenvironment{theglossary}%
     {\begin{longtable}{lll}}%
     {\end{longtable}}%
  % no header:
  \renewcommand*{\glossaryheader}{}%
  % no group headings:
  \renewcommand*{\glsgroupheading}[1]{}%
  % main (level 0) entries displayed in a row
  \renewcommand{\glossentry}[2]{%
    % name in bold:
    \glsentryitem{##1}\glstarget{##1}{\textbf{\glossentryname{##1}}} &
    % symbol in square brackets
    [\glossentrysymbol{##1}] &
    % description in italic
    \textit{\glossentrydesc{##1}}\tabularnewline
  }%
  % sub-entries (same as main)
  \renewcommand{\subglossentry}[3]{\glossentry{##2}{##3}}%
  % blank row between groups if nogroupskip=false
  \ifglsnogroupskip
    \renewcommand*{\glsgroupskip}{}%
  \else
    \renewcommand*{\glsgroupskip}{ & & \tabularnewline}%
  \fi
}

\setglossarystyle{ipa}

\newglossaryentry{accelerator}
{
  name={accelerator},
  symbol={\textipa{@k\textprimstress sel.@.reI.t@\super r}},
  description={the meaning}
}

\glsaddall

\begin{document}
\printglossaries

\end{document}

Glossary accelerator ək'sel.ə.reI.tər the meaning

If your description is likely to be too long for a single row, you'll need to change the column specifier. You'll have to work out the best width according to your document. Example:

\documentclass{book}

\usepackage{tipa}
\usepackage{array}
\usepackage{longtable}
\usepackage{glossaries}

\makeglossaries

\newglossarystyle{ipa}
{%
  % longtable with three columns:
  \renewenvironment{theglossary}%
     {\begin{longtable}{ll>{\raggedright}p{.5\linewidth}}}%
     {\end{longtable}}%
  % no header:
  \renewcommand*{\glossaryheader}{}%
  % no group headings:
  \renewcommand*{\glsgroupheading}[1]{}%
  % main (level 0) entries displayed in a row
  \renewcommand{\glossentry}[2]{%
    % name in bold:
    \glsentryitem{##1}\glstarget{##1}{\textbf{\glossentryname{##1}}} &
    % symbol in square brackets
    [\glossentrysymbol{##1}] &
    % description in italic
    \textit{\glossentrydesc{##1}}\tabularnewline
  }%
  % sub-entries (same as main)
  \renewcommand{\subglossentry}[3]{\glossentry{##2}{##3}}%
  % blank row between groups if nogroupskip=false
  \ifglsnogroupskip
    \renewcommand*{\glsgroupskip}{}%
  \else
    \renewcommand*{\glsgroupskip}{ & & \tabularnewline}%
  \fi
}

\setglossarystyle{ipa}

\newglossaryentry{accelerator}
{
  name={accelerator},
  symbol={\textipa{@k\textprimstress sel.@.reI.t@\super r}},
  description={the meaning}
}

\glsaddall

\begin{document}
\printglossaries

\end{document}
Related Question