LaTeX forum ⇒ MakeIndex, Nomenclature, Glossaries and Acronymsglossaries / retrieve occurences between delimiters Topic is solved

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

glossaries / retrieve occurences between delimiters

Postby arobase » Sat Apr 14, 2012 8:09 pm

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:

  1. \newglossaryentry{x}{name={X}, description={Role: Played by: }}
  2. \newglossaryentry{y}{name={Y}, description={Role: Played by: }}
  3. \newglossaryentry{z}{name={Z}, description={Role: Played by: }}
  4.  
  5. %First scene
  6.  
  7. Cast %desired : x, y
  8.  
  9. Dialogue between \gls{x} and \gls{y}.
  10.  
  11. %Second scene
  12.  
  13. Cast %desired : z
  14.  
  15. Monologue by \gls{z}.

Tags:

User avatar
nlct
Posts: 266
Joined: Thu Nov 06, 2008 11:15 am
Contact:

Postby nlct » Tue Apr 17, 2012 1:45 pm

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.)
  1. \documentclass{article}
  2.  
  3. \usepackage{etoolbox}
  4. \usepackage{datatool}
  5. \usepackage[counter=scene]{glossaries}
  6.  
  7. \makeglossaries
  8.  
  9. \newcounter{scene}
  10. \newcommand*{\scene}{\refstepcounter{scene}\section*{Scene~\thescene}}
  11.  
  12. \newglossaryentry{x}{name={X}, description={Role: Played by: }}
  13. \newglossaryentry{y}{name={Y}, description={Role: Played by: }}
  14. \newglossaryentry{z}{name={Z}, description={Role: Played by: }}
  15.  
  16. \def\parseentrynumbers#1#2\relax{%
  17. \ifblank{#2}{}{\parselocation#2\relax}%
  18. }
  19.  
  20. \def\setscenecast#1#2\delimR#3\relax{%
  21. \ifblank{#3}%
  22. {\listcsxadd{scenecast@#2}{#1}}%
  23. {\castrange{#1}{#2}#3}%
  24. }
  25.  
  26. \newcount\loopindex
  27.  
  28. \def\castrange#1#2#3\delimR{%
  29. \dtlforint\loopindex=#2\to#3\step1\do{%
  30. \listcsxadd{scenecast@\number\loopindex}{#1}%
  31. }%
  32. }
  33.  
  34. \def\parselocation\setentrycounter[]#1\glsnumberformat#2#3{%
  35. \setscenecast{\glslabel}#2\delimR\relax\relax
  36. \ifx#3\relax
  37. \let\next\relax
  38. \else
  39. \let\next\parselocation
  40. \fi
  41. \next
  42. }
  43.  
  44. \let\orgentryfield\glossaryentryfield
  45.  
  46. \renewcommand{\glossaryentryfield}[5]{%
  47. \def\glslabel{#1}%
  48. \orgentryfield{#1}{#2}{#3}{#4}{#5}%
  49. }
  50.  
  51. \renewcommand{\glossaryentrynumbers}[1]{%
  52. \parseentrynumbers#1\relax
  53. }
  54.  
  55. \newcommand*{\castlist}{%
  56. \ifcsdef{scenecast@\arabic{scene}}%
  57. {%
  58. \begin{description}
  59. \renewcommand*{\do}[1]{\item[\glsentryname{##1}] \glsentrydesc{##1}}
  60. \dolistcsloop{scenecast@\arabic{scene}}
  61. \end{description}
  62. }%
  63. {}%
  64. }
  65.  
  66. \begin{document}
  67.  
  68. % Complete cast list
  69. \renewcommand{\glossaryname}{Cast List}
  70. \printglossaries
  71.  
  72. \scene
  73. \castlist
  74.  
  75. Dialogue between \gls{x} and \gls{y}
  76.  
  77. \scene
  78. \castlist
  79.  
  80. Monologue by \gls{z}.
  81.  
  82. \scene
  83. \castlist
  84.  
  85. Scene with \gls{x}, \gls{y} and \gls{z}
  86.  
  87. \scene
  88. \castlist
  89.  
  90. Another monologue by \gls{z}.
  91.  
  92. \end{document}


Regards
Nicola Talbot

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

Postby toms125 » Mon Feb 04, 2013 11:55 am

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: 266
Joined: Thu Nov 06, 2008 11:15 am
Contact:

Postby nlct » Tue Feb 05, 2013 10:44 am

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

Postby toms125 » Tue Feb 05, 2013 12:58 pm

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

  1. \documentclass[11pt,a4paper,twoside]{report}
  2.  
  3. \RequirePackage[english]{babel}
  4.  
  5. \usepackage{etoolbox}
  6. \usepackage{datatool}
  7. \usepackage[nomain,acronym,shortcuts,counter=chapter]{glossaries}
  8.  
  9. \glsSetCompositor{-} %For the package to work with the specific type of page numbering
  10.  
  11. \newglossary[slg]{symbols}{sym}{sbl}{List of Symbols}
  12.  
  13. \makeglossaries
  14.  
  15. %List of symbols - definitions
  16. \newglossaryentry{Ppv}{type=symbols,name=\ensuremath{P_{\rm PV}},
  17. symbol=\si{\watt},sort=Ppv,
  18. description=Power extracted from the PV panels}
  19. \newglossaryentry{Pdc}{type=symbols,name=\ensuremath{P_{\rm dc}},
  20. symbol=\si{\watt},sort=Pdc,
  21. description=Power at the input of the CSI}
  22. \newglossaryentry{Idc}{type=symbols,name=\ensuremath{I_{\rm dc}},
  23. symbol=\si{\ampere},sort=Idc,
  24. description=Current on the DC link at the output of the PV panels}
  25. \newglossaryentry{Vpv}{type=symbols,name=\ensuremath{V_{\rm PV}},
  26. symbol=\si{\volt},sort=Vpv,
  27. description=Voltage at the output of the PV panels}
  28.  
  29. %Acronyms - definitions
  30. \newacronym{APF}{APF}{Active Power Filter}
  31. \newacronym{BESS}{BESS}{Battery Energy Storage System}
  32. \newacronym{CSI}{CSI}{Current Source Inverter}
  33. \newacronym{CC}{CC}{Current-Control}
  34.  
  35. %%%%To cast the list of symbols inside each chapter
  36.  
  37. \def\parseentrynumbers#1#2\relax{%
  38. \ifblank{#2}{}{\parselocation#2\relax}%
  39. }
  40.  
  41. \def\setchaptercast#1#2\delimR#3\relax{%
  42. \ifblank{#3}%
  43. {\listcsxadd{chaptercast@#2}{#1}}%
  44. {\castrange{#1}{#2}#3}%
  45. }
  46.  
  47. \newcount\loopindex
  48.  
  49. \def\castrange#1#2#3\delimR{%
  50. \dtlforint\loopindex=#2\to#3\step1\do{%
  51. \listcsxadd{chaptercast@\number\loopindex}{#1}%
  52. }%
  53. }
  54.  
  55. \def\parselocation\setentrycounter[]#1\glsnumberformat#2#3{%
  56. \setchaptercast{\glslabel}#2\delimR\relax\relax
  57. \ifx#3\relax
  58. \let\next\relax
  59. \else
  60. \let\next\parselocation
  61. \fi
  62. \next
  63. }
  64.  
  65. \let\orgentryfield\glossaryentryfield
  66.  
  67. \renewcommand{\glossaryentryfield}[5]{%
  68. \def\glslabel{#1}%
  69. \orgentryfield{#1}{#2}{#3}{#4}{#5}%
  70. }
  71.  
  72.  
  73. \renewcommand{\glossaryentrynumbers}[1]{%
  74. \parseentrynumbers#1\relax
  75. }
  76.  
  77. %To align the columns
  78. \newcommand{\itab}[1]{\hspace{0em}\rlap{#1}}
  79. \newcommand{\taba}[1]{\hspace{.2\textwidth}\rlap{#1}}
  80. \newcommand{\tabb}[1]{\hspace{.7\textwidth}\rlap{#1}}
  81.  
  82. \newcommand*{\symbolsChap}{%
  83. \ifcsdef{chaptercast@\arabic{chapter}}%
  84. {%
  85. \itab{\textbf{Symbol}} \taba{\textbf{Description}} \tabb{\textbf{Units}} \\
  86. \begin{description}
  87. \renewcommand*{\do}[1]{\item \itab{\glsentrytext{##1}} \taba{\glsentrydesc{##1}} \tabb{\glssymbol{##1}}}
  88. \dolistcsloop{chaptercast@\arabic{chapter}}
  89. \end{description}
  90. }%
  91. {}%
  92. }
  93.  
  94. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  95.  
  96. \begin{document}
  97.  
  98. % Acronyms
  99. \printglossary[type=\acronymtype]
  100.  
  101. %The symbols are displayed inside each chapter if the two following commands are activated
  102. %\glsaddall[types=symbols] % To display all the symbols
  103. %\printglossary[type=symbols]
  104.  
  105. \chapter{Example}
  106.  
  107. \ac{APF}
  108. \gls{Pdc}
  109.  
  110. \symbolsChap
  111.  
  112. \ac{BESS}
  113. \gls{Ppv}
  114.  
  115. \chapter{Ex 2}
  116.  
  117. \ac{CSI}
  118. \gls{Idc}
  119. \\
  120. \symbolsChap
  121.  
  122. \ac{CC}
  123. \gls{Vpv}
  124.  
  125. \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.
Reason: added inline code markup

User avatar
nlct
Posts: 266
Joined: Thu Nov 06, 2008 11:15 am
Contact:

Postby nlct » Tue Feb 05, 2013 5:48 pm

Is this what you want:
  1. \documentclass[11pt,a4paper,twoside]{report}
  2.  
  3. \RequirePackage[english]{babel}
  4.  
  5. \usepackage{etoolbox}
  6. \usepackage{datatool}
  7. \usepackage[nomain,acronym,shortcuts,counter=chapter]{glossaries}
  8.  
  9. \glsSetCompositor{-} %For the package to work with the specific type of page numbering
  10.  
  11. \newglossary[slg]{symbols}{sym}{sbl}{List of Symbols}
  12.  
  13. \makeglossaries
  14.  
  15. %List of symbols - definitions
  16. \newglossaryentry{Ppv}{type=symbols,name=\ensuremath{P_{\rm PV}},
  17. symbol=\si{\watt},sort=Ppv,
  18. description=Power extracted from the PV panels}
  19. \newglossaryentry{Pdc}{type=symbols,name=\ensuremath{P_{\rm dc}},
  20. symbol=\si{\watt},sort=Pdc,
  21. description=Power at the input of the CSI}
  22. \newglossaryentry{Idc}{type=symbols,name=\ensuremath{I_{\rm dc}},
  23. symbol=\si{\ampere},sort=Idc,
  24. description=Current on the DC link at the output of the PV panels}
  25. \newglossaryentry{Vpv}{type=symbols,name=\ensuremath{V_{\rm PV}},
  26. symbol=\si{\volt},sort=Vpv,
  27. description=Voltage at the output of the PV panels}
  28.  
  29. %Acronyms - definitions
  30. \newacronym{APF}{APF}{Active Power Filter}
  31. \newacronym{BESS}{BESS}{Battery Energy Storage System}
  32. \newacronym{CSI}{CSI}{Current Source Inverter}
  33. \newacronym{CC}{CC}{Current-Control}
  34.  
  35. %%%%To cast the list of symbols inside each chapter
  36.  
  37. \def\parseentrynumbers#1#2\relax{%
  38. \ifblank{#2}{}{\parselocation#2\relax}%
  39. }
  40.  
  41. \def\setchaptercast#1#2\delimR#3\relax{%
  42. \ifblank{#3}%
  43. {\listcsxadd{chaptercast@#2}{#1}}%
  44. {\castrange{#1}{#2}#3}%
  45. }
  46.  
  47. \newcount\loopindex
  48.  
  49. \def\castrange#1#2#3\delimR{%
  50. \dtlforint\loopindex=#2\to#3\step1\do{%
  51. \listcsxadd{chaptercast@\number\loopindex}{#1}%
  52. }%
  53. }
  54.  
  55. \def\parselocation\setentrycounter[]#1\glsnumberformat#2#3{%
  56. \setchaptercast{\glslabel}#2\delimR\relax\relax
  57. \ifx#3\relax
  58. \let\next\relax
  59. \else
  60. \let\next\parselocation
  61. \fi
  62. \next
  63. }
  64.  
  65. \let\orgentryfield\glossaryentryfield
  66.  
  67. \newcommand{\castglossaryentryfield}[5]{%
  68. \def\glslabel{#1}%
  69. \orgentryfield{#1}{#2}{#3}{#4}{#5}%
  70. }
  71.  
  72. \newcommand{\castglossaryentrynumbers}[1]{%
  73. \parseentrynumbers#1\relax
  74. }
  75.  
  76. \newcommand{\activatecast}{%
  77. \let\glossaryentryfield\castglossaryentryfield
  78. \let\glossaryentrynumbers\castglossaryentrynumbers
  79. }
  80.  
  81. \newglossarystyle{symbolscan}{%
  82. \renewenvironment{theglossary}{}{}%
  83. \renewcommand*{\glossaryheader}{}%
  84. \renewcommand*{\glsgroupheading}[1]{}%
  85. \renewcommand*{\glsgroupskip}{}%
  86. \renewcommand{\glossaryentryfield}[5]{%
  87. \def\glslabel{##1}%
  88. \let\glossaryentrynumbers\castglossaryentrynumbers
  89. ##5%
  90. }%
  91. \renewcommand{\glossarysubentryfield}[6]{%
  92. \def\glslabel{##2}%
  93. ##6%
  94. }%
  95. }
  96.  
  97. \newcommand{\scansymbollist}{%
  98. \bgroup
  99. \renewcommand{\glossarysection}[2][]{}%
  100. \glossarystyle{symbolscan}%
  101. \InputIfFileExists{\jobname.sym}{}{}%
  102. \egroup
  103. }
  104.  
  105. %To align the columns
  106. \newcommand{\itab}[1]{\hspace{0em}\rlap{#1}}
  107. \newcommand{\taba}[1]{\hspace{.2\textwidth}\rlap{#1}}
  108. \newcommand{\tabb}[1]{\hspace{.7\textwidth}\rlap{#1}}
  109.  
  110. \newcommand*{\symbolsChap}{%
  111. \ifcsdef{chaptercast@\arabic{chapter}}%
  112. {%
  113. \section*{Symbol List}
  114. \itab{\textbf{Symbol}} \taba{\textbf{Description}}
  115. \tabb{\textbf{Units}} \\
  116. \begin{description}\activatecast
  117. \renewcommand*{\do}[1]{\item \itab{\glsentrytext{##1}}
  118. \taba{\glsentrydesc{##1}} \tabb{\glssymbol{##1}}}
  119. \dolistcsloop{chaptercast@\arabic{chapter}}
  120. \end{description}
  121. }%
  122. {}%
  123. }
  124.  
  125.  
  126. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  127.  
  128. \begin{document}
  129.  
  130. % Acronyms
  131. \printglossary[type=\acronymtype]
  132.  
  133. \scansymbollist
  134.  
  135. \chapter{Example}
  136.  
  137. \ac{APF}.
  138. \gls{Pdc}
  139.  
  140. \symbolsChap
  141.  
  142. \ac{BESS}.
  143. \gls{Ppv}.
  144.  
  145. \chapter{Ex 2}
  146.  
  147. \ac{CSI}
  148. \gls{Idc}
  149. \\
  150. \symbolsChap
  151.  
  152. \ac{CC}
  153. \gls{Vpv}
  154.  
  155. \end{document}


Regards
Nicola Talbot

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

Postby toms125 » Tue Feb 05, 2013 8:48 pm

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: 266
Joined: Thu Nov 06, 2008 11:15 am
Contact:

Postby nlct » Sat Feb 09, 2013 8:46 pm

Perhaps use \makebox and \parbox:
  1. \newcommand{\itab}[1]{\makebox[.2\textwidth][l]{#1}}
  2. \newcommand{\taba}[1]{\parbox[t]{.6\textwidth}{#1}}
  3. \newcommand{\tabb}[1]{\makebox[.05\textwidth][c]{#1}}
  4.  
  5. \newcommand*{\symbolsChap}{%
  6. \ifcsdef{chaptercast@\arabic{chapter}}%
  7. {%
  8. \section*{Symbol List}
  9. \itab{\textbf{Symbol}}\hfill
  10. \taba{\textbf{Description}}\hfill
  11. \tabb{\textbf{Units}}\par
  12. \bgroup
  13. \activatecast
  14. \renewcommand{\do}[1]{\noindent
  15. \itab{\glsentrytext{##1}}\hfill
  16. \taba{\glsentrydesc{##1}}\hfill
  17. \tabb{\glssymbol{##1}}\par}
  18. \dolistcsloop{chaptercast@\arabic{chapter}}
  19. \egroup
  20. }%
  21. {}%
  22. }
  23.  

Regards
Nicola Talbot

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

Postby toms125 » Tue May 27, 2014 10:45 am

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.

  1. \documentclass[11pt,a4paper,twoside]{report}
  2.  
  3. \RequirePackage[english]{babel}
  4. \usepackage{etoolbox}
  5. \usepackage{datatool}
  6. \usepackage[nomain,acronym,shortcuts,counter=chapter]{glossaries}
  7.  
  8. \glsSetCompositor{-} %For the package to work with the specific type of page numbering
  9.  
  10. \newglossary[slg]{symbols}{sym}{sbl}{List of Symbols}
  11.  
  12. \makeglossaries
  13.  
  14. %List of symbols - definitions
  15. \newglossaryentry{Ppv}{type=symbols,name=\ensuremath{P_{\rm PV}},
  16. symbol=\si{\watt},sort=Ppv,
  17. description=Power extracted from the PV panels}
  18. \newglossaryentry{Pdc}{type=symbols,name=\ensuremath{P_{\rm dc}},
  19. symbol=\si{\watt},sort=Pdc,
  20. description=Power at the input of the CSI}
  21. \newglossaryentry{Idc}{type=symbols,name=\ensuremath{I_{\rm dc}},
  22. symbol=\si{\ampere},sort=Idc,
  23. description=Current on the DC link at the output of the PV panels}
  24. \newglossaryentry{Vpv}{type=symbols,name=\ensuremath{V_{\rm PV}},
  25. symbol=\si{\volt},sort=Vpv,
  26. description=Voltage at the output of the PV panels}
  27.  
  28. %Acronyms - definitions
  29. \newacronym{APF}{APF}{Active Power Filter}
  30. \newacronym{BESS}{BESS}{Battery Energy Storage System}
  31. \newacronym{CSI}{CSI}{Current Source Inverter}
  32. \newacronym{CC}{CC}{Current-Control}
  33.  
  34. %%%%To cast the list of symbols inside each chapter
  35.  
  36. \def\parseentrynumbers#1#2\relax{%
  37. \ifblank{#2}{}{\parselocation#2\relax}%
  38. }
  39.  
  40. \def\setchaptercast#1#2\delimR#3\relax{%
  41. \ifblank{#3}%
  42. {\listcsxadd{chaptercast@#2}{#1}}%
  43. {\castrange{#1}{#2}#3}%
  44. }
  45.  
  46. \newcount\loopindex
  47.  
  48. \def\castrange#1#2#3\delimR{%
  49. \dtlforint\loopindex=#2\to#3\step1\do{%
  50. \listcsxadd{chaptercast@\number\loopindex}{#1}%
  51. }%
  52. }
  53.  
  54. \def\parselocation\setentrycounter[]#1\glsnumberformat#2#3{%
  55. \setchaptercast{\glslabel}#2\delimR\relax\relax
  56. \ifx#3\relax
  57. \let\next\relax
  58. \else
  59. \let\next\parselocation
  60. \fi
  61. \next
  62. }
  63.  
  64. \let\orgentryfield\glossaryentryfield
  65.  
  66. \newcommand{\castglossaryentryfield}[5]{%
  67. \def\glslabel{#1}%
  68. \orgentryfield{#1}{#2}{#3}{#4}{#5}%
  69. }
  70.  
  71. \newcommand{\castglossaryentrynumbers}[1]{%
  72. \parseentrynumbers#1\relax
  73. }
  74.  
  75. \newcommand{\activatecast}{%
  76. \let\glossaryentryfield\castglossaryentryfield
  77. \let\glossaryentrynumbers\castglossaryentrynumbers
  78. }
  79.  
  80. \newglossarystyle{symbolscan}{%
  81. \renewenvironment{theglossary}{}{}%
  82. \renewcommand*{\glossaryheader}{}%
  83. \renewcommand*{\glsgroupheading}[1]{}%
  84. \renewcommand*{\glsgroupskip}{}%
  85. \renewcommand{\glossaryentryfield}[5]{%
  86. \def\glslabel{##1}%
  87. \let\glossaryentrynumbers\castglossaryentrynumbers
  88. ##5%
  89. }%
  90. \renewcommand{\glossarysubentryfield}[6]{%
  91. \def\glslabel{##2}%
  92. ##6%
  93. }%
  94. }
  95.  
  96. \newcommand{\scansymbollist}{%
  97. \bgroup
  98. \renewcommand{\glossarysection}[2][]{}%
  99. \glossarystyle{symbolscan}%
  100. \InputIfFileExists{\jobname.sym}{}{}%
  101. \egroup
  102. }
  103.  
  104. %To align the columns
  105. \newcommand{\itab}[1]{\hspace{0em}\rlap{#1}}
  106. \newcommand{\taba}[1]{\hspace{.2\textwidth}\rlap{#1}}
  107. \newcommand{\tabb}[1]{\hspace{.7\textwidth}\rlap{#1}}
  108.  
  109. \newcommand*{\symbolsChap}{%
  110. \ifcsdef{chaptercast@\arabic{chapter}}%
  111. {%
  112. \section*{Symbol List}
  113. \itab{\textbf{Symbol}} \taba{\textbf{Description}}
  114. \tabb{\textbf{Units}} \\
  115. \begin{description}\activatecast
  116. \renewcommand*{\do}[1]{\item \itab{\glsentrytext{##1}}
  117. \taba{\glsentrydesc{##1}} \tabb{\glssymbol{##1}}}
  118. \dolistcsloop{chaptercast@\arabic{chapter}}
  119. \end{description}
  120. }%
  121. {}%
  122. }
  123.  
  124.  
  125. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  126.  
  127. \begin{document}
  128.  
  129. % Acronyms
  130. \printglossary[type=\acronymtype]
  131.  
  132. \scansymbollist
  133.  
  134. \chapter{Example}
  135.  
  136. \ac{APF}.
  137. \gls{Pdc}
  138.  
  139. \symbolsChap
  140.  
  141. \ac{BESS}.
  142. \gls{Ppv}.
  143.  
  144. \chapter{Ex 2}
  145.  
  146. \ac{CSI}
  147. \gls{Idc}
  148. \gls{Pdc}
  149. \\
  150. \symbolsChap
  151.  
  152. \ac{CC}
  153. \gls{Vpv}
  154.  
  155. \end{document}


Would you know how to solve this problem?

Thank a lot

Thomas Geury

User avatar
nlct
Posts: 266
Joined: Thu Nov 06, 2008 11:15 am
Contact:

Postby nlct » Mon Jun 09, 2014 3:48 pm

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:

  1. makeindex -s "test.ist" -t "test.alg" -o "test.acr" "test.acn"
  2. 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:

  1. \documentclass[11pt,a4paper,twoside]{report}
  2.  
  3. \RequirePackage[english]{babel}
  4. \usepackage{siunitx}
  5. \usepackage{etoolbox}
  6. \usepackage{datatool}
  7. \usepackage[nomain,acronym,shortcuts,counter=chapter]{glossaries}
  8.  
  9. \glsSetCompositor{-} %For the package to work with the specific type of page numbering
  10.  
  11. \newglossary[slg]{symbols}{sym}{sbl}{List of Symbols}
  12.  
  13. \makeglossaries
  14.  
  15. %List of symbols - definitions
  16. \newglossaryentry{Ppv}{type=symbols,name=\ensuremath{P_{\rm PV}},
  17. symbol=\si{\watt},sort=Ppv,
  18. description=Power extracted from the PV panels}
  19. \newglossaryentry{Pdc}{type=symbols,name=\ensuremath{P_{\rm dc}},
  20. symbol=\si{\watt},sort=Pdc,
  21. description=Power at the input of the CSI}
  22. \newglossaryentry{Idc}{type=symbols,name=\ensuremath{I_{\rm dc}},
  23. symbol=\si{\ampere},sort=Idc,
  24. description=Current on the DC link at the output of the PV panels}
  25. \newglossaryentry{Vpv}{type=symbols,name=\ensuremath{V_{\rm PV}},
  26. symbol=\si{\volt},sort=Vpv,
  27. description=Voltage at the output of the PV panels}
  28.  
  29. %Acronyms - definitions
  30. \newacronym{APF}{APF}{Active Power Filter}
  31. \newacronym{BESS}{BESS}{Battery Energy Storage System}
  32. \newacronym{CSI}{CSI}{Current Source Inverter}
  33. \newacronym{CC}{CC}{Current-Control}
  34.  
  35. %%%%To cast the list of symbols inside each chapter
  36.  
  37. \def\parseentrynumbers#1#2\relax{%
  38. \ifblank{#2}{}{\parselocation#2\relax}%
  39. }
  40.  
  41. \def\setchaptercast#1#2\delimR#3\relax{%
  42. \ifblank{#3}%
  43. {\listcsxadd{chaptercast@#2}{#1}}%
  44. {\castrange{#1}{#2}#3}%
  45. }
  46.  
  47. \newcount\loopindex
  48.  
  49. \def\castrange#1#2#3\delimR{%
  50. \dtlforint\loopindex=#2\to#3\step1\do{%
  51. \listcsxadd{chaptercast@\number\loopindex}{#1}%
  52. }%
  53. }
  54.  
  55. \def\parselocation\setentrycounter[]#1\glsnumberformat#2#3{%
  56. \setchaptercast{\glslabel}#2\delimR\relax\relax
  57. \ifx\relax#3\relax
  58. \let\next\relax
  59. \else
  60. \let\next\parselocation
  61. \fi
  62. \next
  63. }
  64.  
  65. \let\orgentryfield\glossaryentryfield
  66.  
  67. \newcommand{\castglossaryentryfield}[5]{%
  68. \def\glslabel{#1}%
  69. \orgentryfield{#1}{#2}{#3}{#4}{#5}%
  70. }
  71.  
  72. \newcommand{\castglossaryentrynumbers}[1]{%
  73. \parseentrynumbers#1\relax
  74. }
  75.  
  76. \newcommand{\activatecast}{%
  77. \let\glossaryentryfield\castglossaryentryfield
  78. \let\glossaryentrynumbers\castglossaryentrynumbers
  79. }
  80.  
  81. \newglossarystyle{symbolscan}{%
  82. \renewenvironment{theglossary}{}{}%
  83. \renewcommand*{\glossaryheader}{}%
  84. \renewcommand*{\glsgroupheading}[1]{}%
  85. \renewcommand*{\glsgroupskip}{}%
  86. \renewcommand{\glossaryentryfield}[5]{%
  87. \def\glslabel{##1}%
  88. \let\glossaryentrynumbers\castglossaryentrynumbers
  89. ##5%
  90. }%
  91. \renewcommand{\glossarysubentryfield}[6]{%
  92. \def\glslabel{##2}%
  93. ##6%
  94. }%
  95. }
  96.  
  97. \newcommand{\scansymbollist}{%
  98. \bgroup
  99. \renewcommand{\glossarysection}[2][]{}%
  100. \glossarystyle{symbolscan}%
  101. \def\currentglossary{symbols}%
  102. \InputIfFileExists{\jobname.sym}{}{}%
  103. \egroup
  104. }
  105.  
  106. %To align the columns
  107. \newcommand{\itab}[1]{\hspace{0em}\rlap{#1}}
  108. \newcommand{\taba}[1]{\hspace{.2\textwidth}\rlap{#1}}
  109. \newcommand{\tabb}[1]{\hspace{.7\textwidth}\rlap{#1}}
  110.  
  111. \newcommand*{\symbolsChap}{%
  112. \ifcsdef{chaptercast@\arabic{chapter}}%
  113. {%
  114. \section*{Symbol List}
  115. \itab{\textbf{Symbol}} \taba{\textbf{Description}}
  116. \tabb{\textbf{Units}} \\
  117. \begin{description}\activatecast
  118. \renewcommand*{\do}[1]{\item \itab{\glsentrytext{##1}}
  119. \taba{\glsentrydesc{##1}} \tabb{\glssymbol{##1}}}
  120. \dolistcsloop{chaptercast@\arabic{chapter}}
  121. \end{description}
  122. }%
  123. {}%
  124. }
  125.  
  126.  
  127. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  128.  
  129. \begin{document}
  130.  
  131. % Acronyms
  132. \printglossary[type=\acronymtype]
  133.  
  134. \scansymbollist
  135.  
  136. \chapter{Example}
  137.  
  138. \ac{APF}.
  139. \gls{Pdc}
  140.  
  141. \symbolsChap
  142.  
  143. \ac{BESS}.
  144. \gls{Ppv}.
  145.  
  146. \chapter{Ex 2}
  147.  
  148. \ac{CSI}
  149. \gls{Idc}
  150. \gls{Pdc}
  151. \\
  152. \symbolsChap
  153.  
  154. \ac{CC}
  155. \gls{Vpv}
  156.  
  157. \end{document}


Regards
Nicola Talbot


Return to “MakeIndex, Nomenclature, Glossaries and Acronyms”

Who is online

Users browsing this forum: No registered users and 1 guest