PageRenderTime 39ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/Master/texmf-dist/tex/latex/acro/acro0.def

https://bitbucket.org/preining/tex-live
Module-Definition | 169 lines | 158 code | 11 blank | 0 comment | 0 complexity | dcb3371f45333c05d887de9a2cfc14c0 MD5 | raw file
  1. % --------------------------------------------------------------------------
  2. % the ACRO package
  3. %
  4. % Typeset Acronyms
  5. %
  6. % --------------------------------------------------------------------------
  7. % Clemens Niederberger
  8. % Web: https://bitbucket.org/cgnieder/acro/
  9. % E-Mail: contact@mychemistry.eu
  10. % --------------------------------------------------------------------------
  11. % Copyright 2011-2013 Clemens Niederberger
  12. %
  13. % This work may be distributed and/or modified under the
  14. % conditions of the LaTeX Project Public License, either version 1.3
  15. % of this license or (at your option) any later version.
  16. % The latest version of this license is in
  17. % http://www.latex-project.org/lppl.txt
  18. % and version 1.3 or later is part of all distributions of LaTeX
  19. % version 2005/12/01 or later.
  20. %
  21. % This work has the LPPL maintenance status `maintained'.
  22. %
  23. % The Current Maintainer of this work is Clemens Niederberger.
  24. % --------------------------------------------------------------------------
  25. % The acro package consists of the files
  26. % - acro.sty, acro0.def, acro1.def, acro_en.tex, acro_en.pdf, README
  27. % --------------------------------------------------------------------------
  28. % If you have any ideas, questions, suggestions or bugs to report, please
  29. % feel free to contact me.
  30. % --------------------------------------------------------------------------
  31. \ProvidesFile{acro0.def}
  32. % --------------------------------------------------------------------------
  33. % adding an acronym, internal command:
  34. % #1: use/replace plural (boolean)
  35. % #2: id
  36. % #3: short
  37. % #4: short plural
  38. % #5: alt
  39. % #6: long
  40. % #7: long plural
  41. % #8: class
  42. % #9: extra
  43. \cs_new:Npn \acro_new:nnnnnnnnn #1#2#3#4#5#6#7#8#9
  44. {
  45. \IfBooleanTF { #1 }
  46. { \prop_put:Nnn \l__acro_replace_plural_prop { #2 } { \c_true_bool } }
  47. { \prop_put:Nnn \l__acro_replace_plural_prop { #2 } { \c_false_bool } }
  48. \prop_put:Nnn \l__acro_short_prop { #2 } { #3 }
  49. \prop_put:Nnn \l__acro_sort_prop { #2 } { #2 }
  50. \prop_put:Nnn \l__acro_pdfstring_prop { #2 } { #3 }
  51. \acro_create_page_records:n { #2 }
  52. \IfNoValueTF { #4 }
  53. {
  54. \prop_put:Nnn \l__acro_short_plural_prop
  55. { #2 } { \l__acro_default_plural_tl }
  56. \prop_put:Nnx \l__acro_pdfstring_plural_prop
  57. { #2 } { \exp_not:n { #3 } \exp_not:V \l__acro_default_plural_tl }
  58. }
  59. {
  60. \prop_put:Nnn \l__acro_short_plural_prop { #2 } { #4 }
  61. \prop_put:Nnx \l__acro_pdfstring_plural_prop { #2 } { \exp_not:n { #3 #4 } }
  62. }
  63. \IfNoValueTF { #5 }
  64. { \prop_put:Nnn \l__acro_alt_prop { #2 } { #2 } }
  65. { \prop_put:Nnn \l__acro_alt_prop { #2 } { #5 } }
  66. \prop_put:Nnn \l__acro_long_prop { #2 } { #6 }
  67. \IfNoValueTF { #7 }
  68. { \prop_put:Nnn \l__acro_long_plural_prop { #2 } { \l__acro_default_plural_tl } }
  69. { \prop_put:Nnn \l__acro_long_plural_prop { #2 } { #7 } }
  70. \IfNoValueF { #8 }
  71. { \prop_put:Nnn \l__acro_class_prop { #2 } { #8 } }
  72. \IfNoValueF { #9 }
  73. { \prop_put:Nnn \l__acro_extra_prop { #2 } { #9 } }
  74. \bool_new:c { g__acro_#2_first_use_bool }
  75. \bool_new:c { g__acro_#2_used_bool }
  76. \bool_new:c { g__acro_#2_label_bool }
  77. \bool_if:NT \l__acro_create_macros_bool
  78. {
  79. \cs_if_exist:cTF { #2 }
  80. {
  81. \bool_if:NT \l__acro_strict_bool
  82. { \cs_set:cpn { #2 } { \ac { #2 } \acro_xspace: } }
  83. }
  84. { \cs_new:cpn { #2 } { \ac { #2 } \acro_xspace: } }
  85. }
  86. }
  87. % set custom format:
  88. \cs_new:Npn \acro_format:nn #1#2
  89. { \prop_put:Nnn \l__acro_format_prop { #1 } { #2 } }
  90. % add citation:
  91. \cs_new:Npn \acro_citation:nnnn #1#2#3#4
  92. {
  93. \prop_put:Nnn \l__acro_citation_prop { #1 } { #4 }
  94. \IfNoValueF { #2 }
  95. { \prop_put:Nnn \l__acro_citation_pre_prop { #1 } { #2 } }
  96. \IfNoValueF { #3 }
  97. { \prop_put:Nnn \l__acro_citation_post_prop { #1 } { #3 } }
  98. }
  99. % add pdfstring:
  100. \cs_new:Npn \acro_pdfstring:nnn #1#2#3
  101. {
  102. \prop_put:Nnx \l__acro_pdfstring_prop { #1 } { #2 }
  103. \IfNoValueTF { #3 }
  104. {
  105. \prop_put:Nnx \l__acro_pdfstring_plural_prop
  106. { #1 } { #2 \l__acro_default_plural_tl }
  107. }
  108. {
  109. \prop_put:Nnx \l__acro_pdfstring_plural_prop
  110. { #1 } { #2 #3 }
  111. }
  112. }
  113. % --------------------------------------------------------------------------
  114. % USER COMMANDS
  115. % adding an acronym, user command:
  116. % #1: use/replace plural (boolean)
  117. % #2: id
  118. % #3: short
  119. % #4: short plural
  120. % #5: alt
  121. % #6: long
  122. % #7: long plural
  123. % #8: class
  124. % #9: extra
  125. \NewDocumentCommand \DeclareAcronym
  126. { sm>{\SplitArgument{1}{,}}mo>{\SplitArgument{1}{,}}+mgo }
  127. { \acro_new:nnnnnnnnn { #1 } { #2 } #3 { #4 } #5 { #7 } { #6 } }
  128. \@onlypreamble \DeclareAcronym
  129. \NewDocumentCommand \DeclareAcronymFormat { mm }
  130. { \acro_format:nn { #1 } { #2 } }
  131. \@onlypreamble \DeclareAcronymFormat
  132. \NewDocumentCommand \DeclareAcronymCitation { moom }
  133. { \acro_citation:nnnn { #1 } { #2 } { #3 } { #4 } }
  134. \@onlypreamble \DeclareAcronymCitation
  135. \NewDocumentCommand \DeclareAcronymPDFString
  136. { m >{ \SplitArgument { 1 } { , } } m }
  137. { \acro_pdfstring:nnn { #1 } #2 }
  138. \@onlypreamble \DeclareAcronymPDFstring
  139. % --------------------------------------------------------------------------
  140. % print the list:
  141. \cs_new:Npn \acro_print_acronyms:nn #1#2
  142. {
  143. \iow_now:Nx \@auxout { \string \acro@print@list }
  144. \bool_if:NT \l__acro_sort_bool
  145. { \acro_sort_prop:N \l__acro_short_prop }
  146. \UseInstance { acro-title } { \l__acro_list_title_tl }
  147. { \l__acro_list_name_tl }
  148. \cs_if_exist:NTF \acro@printed@list
  149. {
  150. \UseInstance { acro-list } { \l__acro_list_instance_tl }
  151. { \l__acro_list_type_tl } { #1 } { #2 }
  152. }
  153. { \@latex@warning@no@line {Rerun~to~get~acronym~list~right} }
  154. }
  155. % user command:
  156. \NewDocumentCommand \printacronyms { G{}O{} }
  157. { \acro_print_acronyms:nn { #1 } { #2 } }
  158. \tex_endinput:D