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