MakeIndex, Nomenclature, Glossaries and Acronymsglossaries / retrieve occurences between delimiters

Information and discussion about MakeIndex - the tool to generate subject indices for LaTeX documents.
Post Reply
arobase
Posts: 33
Joined: Sat Apr 14, 2012 7:46 pm

glossaries / retrieve occurences between delimiters

Post by arobase »

Let's say I'm writing a play involving characters X, Y and Z. I'd like, at the beginning of each scene, to list the characters that included. Is that possible?

Example:

Code: Select all

\newglossaryentry{x}{name={X}, description={Role:  Played by: }}
\newglossaryentry{y}{name={Y}, description={Role:  Played by: }}
\newglossaryentry{z}{name={Z}, description={Role:  Played by: }}

%First scene

Cast %desired : x, y

Dialogue between \gls{x} and \gls{y}.

%Second scene

Cast %desired : z

Monologue by \gls{z}.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

glossaries / retrieve occurences between delimiters

Post by nlct »

This assumes you're using makeindex. The code will have to be modified for xindy. (You'll need to change \scene to whatever's appropriate for your document.)

Code: Select all

\documentclass{article}

\usepackage{etoolbox}
\usepackage{datatool}
\usepackage[counter=scene]{glossaries}

\makeglossaries

\newcounter{scene}
\newcommand*{\scene}{\refstepcounter{scene}\section*{Scene~\thescene}}

\newglossaryentry{x}{name={X}, description={Role:  Played by: }}
\newglossaryentry{y}{name={Y}, description={Role:  Played by: }}
\newglossaryentry{z}{name={Z}, description={Role:  Played by: }}

\def\parseentrynumbers#1#2\relax{%
  \ifblank{#2}{}{\parselocation#2\relax}%
}

\def\setscenecast#1#2\delimR#3\relax{%
  \ifblank{#3}%
   {\listcsxadd{scenecast@#2}{#1}}%
   {\castrange{#1}{#2}#3}%
}

\newcount\loopindex

\def\castrange#1#2#3\delimR{%
   \dtlforint\loopindex=#2\to#3\step1\do{%
      \listcsxadd{scenecast@\number\loopindex}{#1}%
   }% 
}

\def\parselocation\setentrycounter[]#1\glsnumberformat#2#3{%
  \setscenecast{\glslabel}#2\delimR\relax\relax
  \ifx#3\relax
    \let\next\relax
  \else
    \let\next\parselocation
  \fi
  \next
}

\let\orgentryfield\glossaryentryfield

\renewcommand{\glossaryentryfield}[5]{%
  \def\glslabel{#1}%
  \orgentryfield{#1}{#2}{#3}{#4}{#5}%
}

\renewcommand{\glossaryentrynumbers}[1]{%
  \parseentrynumbers#1\relax
}

\newcommand*{\castlist}{%
  \ifcsdef{scenecast@\arabic{scene}}%
  {%
    \begin{description}
    \renewcommand*{\do}[1]{\item[\glsentryname{##1}] \glsentrydesc{##1}}
    \dolistcsloop{scenecast@\arabic{scene}}
    \end{description}
  }%
  {}%
}

\begin{document}

% Complete cast list
\renewcommand{\glossaryname}{Cast List}
\printglossaries

\scene
\castlist

Dialogue between \gls{x} and \gls{y}

\scene
\castlist

Monologue by \gls{z}.

\scene
\castlist

Scene with \gls{x}, \gls{y} and \gls{z}

\scene
\castlist

Another monologue by \gls{z}.

\end{document}
Regards
Nicola Talbot
toms125
Posts: 5
Joined: Fri Feb 01, 2013 5:31 pm

glossaries / retrieve occurences between delimiters

Post by toms125 »

Hello,

I tried your solution in my document where I'm using an acronym-type glossary and a list of symbols that I defined myself using

\newglossary[slg]{symbols}{sym}{sbl}{List of Symbols}

I don't have any "main" glossary. In my case your code displays the acronyms used inside the cast but I would like to display the symbols from List of symbols used inside the cast instead. How is it possible? Also, I would like that the printed list be an unnumbered section named 'List of Symbols'.

Thank you,

Thomas
User avatar
nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

glossaries / retrieve occurences between delimiters

Post by nlct »

Can you provide a minimal example showing what you've tried and how the output differs from what you want. (I'm sorry it's not clear to me exactly what you require.)

Regards
Nicola Talbot
toms125
Posts: 5
Joined: Fri Feb 01, 2013 5:31 pm

glossaries / retrieve occurences between delimiters

Post by toms125 »

Here is a minimal working example, including your code for the cast, which I defined for chapters with the command name \symbolsChap:

Code: Select all

\documentclass[11pt,a4paper,twoside]{report}

\RequirePackage[english]{babel}

\usepackage{etoolbox}
\usepackage{datatool}
\usepackage[nomain,acronym,shortcuts,counter=chapter]{glossaries}

\glsSetCompositor{-} %For the package to work with the specific type of page numbering

\newglossary[slg]{symbols}{sym}{sbl}{List of Symbols}

\makeglossaries

%List of symbols - definitions
\newglossaryentry{Ppv}{type=symbols,name=\ensuremath{P_{\rm PV}},
symbol=\si{\watt},sort=Ppv,
description=Power extracted from the PV panels}
\newglossaryentry{Pdc}{type=symbols,name=\ensuremath{P_{\rm dc}},
symbol=\si{\watt},sort=Pdc,
description=Power at the input of the CSI}
\newglossaryentry{Idc}{type=symbols,name=\ensuremath{I_{\rm dc}},
symbol=\si{\ampere},sort=Idc,
description=Current on the DC link at the output of the PV panels}
\newglossaryentry{Vpv}{type=symbols,name=\ensuremath{V_{\rm PV}},
symbol=\si{\volt},sort=Vpv,
description=Voltage at the output of the PV panels}

%Acronyms - definitions
\newacronym{APF}{APF}{Active Power Filter}
\newacronym{BESS}{BESS}{Battery Energy Storage System}
\newacronym{CSI}{CSI}{Current Source Inverter}
\newacronym{CC}{CC}{Current-Control}

%%%%To cast the list of symbols inside each chapter

\def\parseentrynumbers#1#2\relax{%
  \ifblank{#2}{}{\parselocation#2\relax}%
}

\def\setchaptercast#1#2\delimR#3\relax{%
  \ifblank{#3}%
   {\listcsxadd{chaptercast@#2}{#1}}%
   {\castrange{#1}{#2}#3}%
}

\newcount\loopindex

\def\castrange#1#2#3\delimR{%
   \dtlforint\loopindex=#2\to#3\step1\do{%
      \listcsxadd{chaptercast@\number\loopindex}{#1}%
   }% 
}

\def\parselocation\setentrycounter[]#1\glsnumberformat#2#3{%
  \setchaptercast{\glslabel}#2\delimR\relax\relax
  \ifx#3\relax
    \let\next\relax
  \else
    \let\next\parselocation
  \fi
  \next
}

\let\orgentryfield\glossaryentryfield

\renewcommand{\glossaryentryfield}[5]{%
  \def\glslabel{#1}%
  \orgentryfield{#1}{#2}{#3}{#4}{#5}%
}


\renewcommand{\glossaryentrynumbers}[1]{%
  \parseentrynumbers#1\relax
}

%To align the columns
\newcommand{\itab}[1]{\hspace{0em}\rlap{#1}}
\newcommand{\taba}[1]{\hspace{.2\textwidth}\rlap{#1}}
\newcommand{\tabb}[1]{\hspace{.7\textwidth}\rlap{#1}}

\newcommand*{\symbolsChap}{%
  \ifcsdef{chaptercast@\arabic{chapter}}%
  {%
  \itab{\textbf{Symbol}}  \taba{\textbf{Description}}  \tabb{\textbf{Units}} \\
    \begin{description}
    \renewcommand*{\do}[1]{\item \itab{\glsentrytext{##1}} \taba{\glsentrydesc{##1}} \tabb{\glssymbol{##1}}}
    \dolistcsloop{chaptercast@\arabic{chapter}}
    \end{description}
  }%
  {}%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

% Acronyms
\printglossary[type=\acronymtype]

%The symbols are displayed inside each chapter if the two following commands are activated
%\glsaddall[types=symbols] % To display all the symbols
%\printglossary[type=symbols]

\chapter{Example}

\ac{APF}
\gls{Pdc}

\symbolsChap

\ac{BESS}
\gls{Ppv}

\chapter{Ex 2}

\ac{CSI}
\gls{Idc}
\\
\symbolsChap

\ac{CC}
\gls{Vpv}

\end{document}
The code above displays the acronyms used inside chapter 1 and 2. However, I would like it to display the symbols used inside chapter 1 and 2, each time with the command \symbolsChap.

I noticed that the use of the command \printglossary influences what is printed by \symbolsChap. For instance, if I use \printglossary[type=symbols] as well before the chapters, the symbols will be printed as well by \symbolsChap.

--> My problem: How to print only the symbols inside the chapters with \symbolsChap independently of the use of the command \printglossary?

Also, if possible, I would like the List of symbols printed in each chapter to be an unnumered section with the title 'List of symbols' instead of a list without title.

Thanks for your help!

Thomas
Last edited by cgnieder on Tue Feb 05, 2013 1:11 pm, edited 1 time in total.
User avatar
nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

glossaries / retrieve occurences between delimiters

Post by nlct »

Is this what you want:

Code: Select all

\documentclass[11pt,a4paper,twoside]{report}

\RequirePackage[english]{babel}

\usepackage{etoolbox}
\usepackage{datatool}
\usepackage[nomain,acronym,shortcuts,counter=chapter]{glossaries}

\glsSetCompositor{-} %For the package to work with the specific type of page numbering

\newglossary[slg]{symbols}{sym}{sbl}{List of Symbols}

\makeglossaries

%List of symbols - definitions
\newglossaryentry{Ppv}{type=symbols,name=\ensuremath{P_{\rm PV}},
symbol=\si{\watt},sort=Ppv,
description=Power extracted from the PV panels}
\newglossaryentry{Pdc}{type=symbols,name=\ensuremath{P_{\rm dc}},
symbol=\si{\watt},sort=Pdc,
description=Power at the input of the CSI}
\newglossaryentry{Idc}{type=symbols,name=\ensuremath{I_{\rm dc}},
symbol=\si{\ampere},sort=Idc,
description=Current on the DC link at the output of the PV panels}
\newglossaryentry{Vpv}{type=symbols,name=\ensuremath{V_{\rm PV}},
symbol=\si{\volt},sort=Vpv,
description=Voltage at the output of the PV panels}

%Acronyms - definitions
\newacronym{APF}{APF}{Active Power Filter}
\newacronym{BESS}{BESS}{Battery Energy Storage System}
\newacronym{CSI}{CSI}{Current Source Inverter}
\newacronym{CC}{CC}{Current-Control}

%%%%To cast the list of symbols inside each chapter

\def\parseentrynumbers#1#2\relax{%
  \ifblank{#2}{}{\parselocation#2\relax}%
}

\def\setchaptercast#1#2\delimR#3\relax{%
  \ifblank{#3}%
   {\listcsxadd{chaptercast@#2}{#1}}%
   {\castrange{#1}{#2}#3}%
}

\newcount\loopindex

\def\castrange#1#2#3\delimR{%
   \dtlforint\loopindex=#2\to#3\step1\do{%
      \listcsxadd{chaptercast@\number\loopindex}{#1}%
   }%
}

\def\parselocation\setentrycounter[]#1\glsnumberformat#2#3{%
  \setchaptercast{\glslabel}#2\delimR\relax\relax
  \ifx#3\relax
    \let\next\relax
  \else
    \let\next\parselocation
  \fi
  \next
}

\let\orgentryfield\glossaryentryfield

\newcommand{\castglossaryentryfield}[5]{%
  \def\glslabel{#1}%
  \orgentryfield{#1}{#2}{#3}{#4}{#5}%
}

\newcommand{\castglossaryentrynumbers}[1]{%
  \parseentrynumbers#1\relax
}

\newcommand{\activatecast}{%
  \let\glossaryentryfield\castglossaryentryfield
  \let\glossaryentrynumbers\castglossaryentrynumbers
}

\newglossarystyle{symbolscan}{%
  \renewenvironment{theglossary}{}{}%
  \renewcommand*{\glossaryheader}{}%
  \renewcommand*{\glsgroupheading}[1]{}%
  \renewcommand*{\glsgroupskip}{}%
  \renewcommand{\glossaryentryfield}[5]{%
    \def\glslabel{##1}%
    \let\glossaryentrynumbers\castglossaryentrynumbers
    ##5%
  }%
  \renewcommand{\glossarysubentryfield}[6]{%
    \def\glslabel{##2}%
    ##6%
  }%
}

\newcommand{\scansymbollist}{%
  \bgroup
   \renewcommand{\glossarysection}[2][]{}%
   \glossarystyle{symbolscan}%
   \InputIfFileExists{\jobname.sym}{}{}%
  \egroup
}

%To align the columns
\newcommand{\itab}[1]{\hspace{0em}\rlap{#1}}
\newcommand{\taba}[1]{\hspace{.2\textwidth}\rlap{#1}}
\newcommand{\tabb}[1]{\hspace{.7\textwidth}\rlap{#1}}

\newcommand*{\symbolsChap}{%
  \ifcsdef{chaptercast@\arabic{chapter}}%
  {%
  \section*{Symbol List}
  \itab{\textbf{Symbol}}  \taba{\textbf{Description}}
\tabb{\textbf{Units}} \\
    \begin{description}\activatecast
    \renewcommand*{\do}[1]{\item \itab{\glsentrytext{##1}}
\taba{\glsentrydesc{##1}} \tabb{\glssymbol{##1}}}
    \dolistcsloop{chaptercast@\arabic{chapter}}
    \end{description}
  }%
  {}%
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

% Acronyms
\printglossary[type=\acronymtype]

\scansymbollist

\chapter{Example}

\ac{APF}.
\gls{Pdc}

\symbolsChap

\ac{BESS}.
\gls{Ppv}.

\chapter{Ex 2}

\ac{CSI}
\gls{Idc}
\\
\symbolsChap

\ac{CC}
\gls{Vpv}

\end{document}
Regards
Nicola Talbot
toms125
Posts: 5
Joined: Fri Feb 01, 2013 5:31 pm

glossaries / retrieve occurences between delimiters

Post by toms125 »

Yes that's what i wanted, thanks a lot!

I still have a last issue, I cannot figure out how to align properly the columns of the lists printed with \symbolsChap. I tried something (see my previous code) but it doesn't go to the line when the text is too long. Also, it would be nicer to be able to center the last column (\glssymbol{}). The tab character & would do the work in a proper environment but here it doesn't.

Thanks for the help and for the great package!

Thomas
User avatar
nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

glossaries / retrieve occurences between delimiters

Post by nlct »

Perhaps use \makebox and \parbox:

Code: Select all

    \newcommand{\itab}[1]{\makebox[.2\textwidth][l]{#1}}
    \newcommand{\taba}[1]{\parbox[t]{.6\textwidth}{#1}}
    \newcommand{\tabb}[1]{\makebox[.05\textwidth][c]{#1}}

    \newcommand*{\symbolsChap}{%
      \ifcsdef{chaptercast@\arabic{chapter}}%
      {%
      \section*{Symbol List}
        \itab{\textbf{Symbol}}\hfill
        \taba{\textbf{Description}}\hfill
        \tabb{\textbf{Units}}\par
        \bgroup
         \activatecast
         \renewcommand{\do}[1]{\noindent
          \itab{\glsentrytext{##1}}\hfill
          \taba{\glsentrydesc{##1}}\hfill
          \tabb{\glssymbol{##1}}\par}
         \dolistcsloop{chaptercast@\arabic{chapter}}
        \egroup
      }%
      {}%
    }

Regards
Nicola Talbot
toms125
Posts: 5
Joined: Fri Feb 01, 2013 5:31 pm

glossaries / retrieve occurences between delimiters

Post by toms125 »

Hello,

If I use the same code as above to retrieve the symbols used inside a chapter, the symbols that are used in exactly 2 chapters don't appear in the list anymore. If they are used in more than 2 chapters, then they appear in all the lists of symbols.

Here is a MWE where "Pdc" is used in both chapters and thus disappears for the symbol lists.

Code: Select all

\documentclass[11pt,a4paper,twoside]{report}

\RequirePackage[english]{babel}
\usepackage{etoolbox}
\usepackage{datatool}
\usepackage[nomain,acronym,shortcuts,counter=chapter]{glossaries}

\glsSetCompositor{-} %For the package to work with the specific type of page numbering

\newglossary[slg]{symbols}{sym}{sbl}{List of Symbols}

\makeglossaries

%List of symbols - definitions
\newglossaryentry{Ppv}{type=symbols,name=\ensuremath{P_{\rm PV}},
symbol=\si{\watt},sort=Ppv,
description=Power extracted from the PV panels}
\newglossaryentry{Pdc}{type=symbols,name=\ensuremath{P_{\rm dc}},
symbol=\si{\watt},sort=Pdc,
description=Power at the input of the CSI}
\newglossaryentry{Idc}{type=symbols,name=\ensuremath{I_{\rm dc}},
symbol=\si{\ampere},sort=Idc,
description=Current on the DC link at the output of the PV panels}
\newglossaryentry{Vpv}{type=symbols,name=\ensuremath{V_{\rm PV}},
symbol=\si{\volt},sort=Vpv,
description=Voltage at the output of the PV panels}

%Acronyms - definitions
\newacronym{APF}{APF}{Active Power Filter}
\newacronym{BESS}{BESS}{Battery Energy Storage System}
\newacronym{CSI}{CSI}{Current Source Inverter}
\newacronym{CC}{CC}{Current-Control}

%%%%To cast the list of symbols inside each chapter

\def\parseentrynumbers#1#2\relax{%
  \ifblank{#2}{}{\parselocation#2\relax}%
}

\def\setchaptercast#1#2\delimR#3\relax{%
  \ifblank{#3}%
   {\listcsxadd{chaptercast@#2}{#1}}%
   {\castrange{#1}{#2}#3}%
}

\newcount\loopindex

\def\castrange#1#2#3\delimR{%
   \dtlforint\loopindex=#2\to#3\step1\do{%
      \listcsxadd{chaptercast@\number\loopindex}{#1}%
   }%
}

\def\parselocation\setentrycounter[]#1\glsnumberformat#2#3{%
  \setchaptercast{\glslabel}#2\delimR\relax\relax
  \ifx#3\relax
    \let\next\relax
  \else
    \let\next\parselocation
  \fi
  \next
}

\let\orgentryfield\glossaryentryfield

\newcommand{\castglossaryentryfield}[5]{%
  \def\glslabel{#1}%
  \orgentryfield{#1}{#2}{#3}{#4}{#5}%
}

\newcommand{\castglossaryentrynumbers}[1]{%
  \parseentrynumbers#1\relax
}

\newcommand{\activatecast}{%
  \let\glossaryentryfield\castglossaryentryfield
  \let\glossaryentrynumbers\castglossaryentrynumbers
}

\newglossarystyle{symbolscan}{%
  \renewenvironment{theglossary}{}{}%
  \renewcommand*{\glossaryheader}{}%
  \renewcommand*{\glsgroupheading}[1]{}%
  \renewcommand*{\glsgroupskip}{}%
  \renewcommand{\glossaryentryfield}[5]{%
    \def\glslabel{##1}%
    \let\glossaryentrynumbers\castglossaryentrynumbers
    ##5%
  }%
  \renewcommand{\glossarysubentryfield}[6]{%
    \def\glslabel{##2}%
    ##6%
  }%
}

\newcommand{\scansymbollist}{%
  \bgroup
   \renewcommand{\glossarysection}[2][]{}%
   \glossarystyle{symbolscan}%
   \InputIfFileExists{\jobname.sym}{}{}%
  \egroup
}

%To align the columns
\newcommand{\itab}[1]{\hspace{0em}\rlap{#1}}
\newcommand{\taba}[1]{\hspace{.2\textwidth}\rlap{#1}}
\newcommand{\tabb}[1]{\hspace{.7\textwidth}\rlap{#1}}

\newcommand*{\symbolsChap}{%
  \ifcsdef{chaptercast@\arabic{chapter}}%
  {%
  \section*{Symbol List}
  \itab{\textbf{Symbol}}  \taba{\textbf{Description}}
\tabb{\textbf{Units}} \\
    \begin{description}\activatecast
    \renewcommand*{\do}[1]{\item \itab{\glsentrytext{##1}}
\taba{\glsentrydesc{##1}} \tabb{\glssymbol{##1}}}
    \dolistcsloop{chaptercast@\arabic{chapter}}
    \end{description}
  }%
  {}%
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

% Acronyms
\printglossary[type=\acronymtype]

\scansymbollist

\chapter{Example}

\ac{APF}.
\gls{Pdc}

\symbolsChap

\ac{BESS}.
\gls{Ppv}.

\chapter{Ex 2}

\ac{CSI}
\gls{Idc}
\gls{Pdc}
\\
\symbolsChap

\ac{CC}
\gls{Vpv}

\end{document}
Would you know how to solve this problem?

Thank a lot

Thomas Geury
User avatar
nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

glossaries / retrieve occurences between delimiters

Post by nlct »

I think the implicit range formation applied by makeindex is causing the problem. You can disable it using the -r option, but only for the symbol list since the acronym list displays the page numbers:

Code: Select all

makeindex -s "test.ist" -t "test.alg" -o "test.acr" "test.acn"
makeindex  -r -s "test.ist" -t "test.slg" -o "test.sym" "test.sbl"
(where test.tex is the filename.)

The MWE was missing the siunitx package, and it needs a slight modification to \scansymbollist to ensure it works with the latest version of glossaries. Here's the modified version:

Code: Select all

    \documentclass[11pt,a4paper,twoside]{report}

    \RequirePackage[english]{babel}
    \usepackage{siunitx}
    \usepackage{etoolbox}
    \usepackage{datatool}
    \usepackage[nomain,acronym,shortcuts,counter=chapter]{glossaries}

    \glsSetCompositor{-} %For the package to work with the specific type of page numbering

    \newglossary[slg]{symbols}{sym}{sbl}{List of Symbols}

    \makeglossaries

    %List of symbols - definitions
    \newglossaryentry{Ppv}{type=symbols,name=\ensuremath{P_{\rm PV}},
    symbol=\si{\watt},sort=Ppv,
    description=Power extracted from the PV panels}
    \newglossaryentry{Pdc}{type=symbols,name=\ensuremath{P_{\rm dc}},
    symbol=\si{\watt},sort=Pdc,
    description=Power at the input of the CSI}
    \newglossaryentry{Idc}{type=symbols,name=\ensuremath{I_{\rm dc}},
    symbol=\si{\ampere},sort=Idc,
    description=Current on the DC link at the output of the PV panels}
    \newglossaryentry{Vpv}{type=symbols,name=\ensuremath{V_{\rm PV}},
    symbol=\si{\volt},sort=Vpv,
    description=Voltage at the output of the PV panels}

    %Acronyms - definitions
    \newacronym{APF}{APF}{Active Power Filter}
    \newacronym{BESS}{BESS}{Battery Energy Storage System}
    \newacronym{CSI}{CSI}{Current Source Inverter}
    \newacronym{CC}{CC}{Current-Control}

    %%%%To cast the list of symbols inside each chapter

    \def\parseentrynumbers#1#2\relax{%
      \ifblank{#2}{}{\parselocation#2\relax}%
    }

    \def\setchaptercast#1#2\delimR#3\relax{%
      \ifblank{#3}%
       {\listcsxadd{chaptercast@#2}{#1}}%
       {\castrange{#1}{#2}#3}%
    }

    \newcount\loopindex

    \def\castrange#1#2#3\delimR{%
       \dtlforint\loopindex=#2\to#3\step1\do{%
          \listcsxadd{chaptercast@\number\loopindex}{#1}%
       }%
    }

    \def\parselocation\setentrycounter[]#1\glsnumberformat#2#3{%
      \setchaptercast{\glslabel}#2\delimR\relax\relax
      \ifx\relax#3\relax
        \let\next\relax
      \else
        \let\next\parselocation
      \fi
      \next
    }

    \let\orgentryfield\glossaryentryfield

    \newcommand{\castglossaryentryfield}[5]{%
      \def\glslabel{#1}%
      \orgentryfield{#1}{#2}{#3}{#4}{#5}%
    }

    \newcommand{\castglossaryentrynumbers}[1]{%
      \parseentrynumbers#1\relax
    }

    \newcommand{\activatecast}{%
      \let\glossaryentryfield\castglossaryentryfield
      \let\glossaryentrynumbers\castglossaryentrynumbers
    }

    \newglossarystyle{symbolscan}{%
      \renewenvironment{theglossary}{}{}%
      \renewcommand*{\glossaryheader}{}%
      \renewcommand*{\glsgroupheading}[1]{}%
      \renewcommand*{\glsgroupskip}{}%
      \renewcommand{\glossaryentryfield}[5]{%
        \def\glslabel{##1}%
        \let\glossaryentrynumbers\castglossaryentrynumbers
        ##5%
      }%
      \renewcommand{\glossarysubentryfield}[6]{%
        \def\glslabel{##2}%
        ##6%
      }%
    }

    \newcommand{\scansymbollist}{%
      \bgroup
       \renewcommand{\glossarysection}[2][]{}%
       \glossarystyle{symbolscan}%
       \def\currentglossary{symbols}%
       \InputIfFileExists{\jobname.sym}{}{}%
      \egroup
    }

    %To align the columns
    \newcommand{\itab}[1]{\hspace{0em}\rlap{#1}}
    \newcommand{\taba}[1]{\hspace{.2\textwidth}\rlap{#1}}
    \newcommand{\tabb}[1]{\hspace{.7\textwidth}\rlap{#1}}

    \newcommand*{\symbolsChap}{%
      \ifcsdef{chaptercast@\arabic{chapter}}%
      {%
      \section*{Symbol List}
      \itab{\textbf{Symbol}}  \taba{\textbf{Description}}
    \tabb{\textbf{Units}} \\
        \begin{description}\activatecast
        \renewcommand*{\do}[1]{\item \itab{\glsentrytext{##1}}
    \taba{\glsentrydesc{##1}} \tabb{\glssymbol{##1}}}
        \dolistcsloop{chaptercast@\arabic{chapter}}
        \end{description}
      }%
      {}%
    }


    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    \begin{document}

    % Acronyms
    \printglossary[type=\acronymtype]

    \scansymbollist

    \chapter{Example}

    \ac{APF}.
    \gls{Pdc}

    \symbolsChap

    \ac{BESS}.
    \gls{Ppv}.

    \chapter{Ex 2}

    \ac{CSI}
    \gls{Idc}
    \gls{Pdc}
    \\
    \symbolsChap

    \ac{CC}
    \gls{Vpv}

    \end{document}
Regards
Nicola Talbot
Post Reply