├── HISTORY ├── LICENSE ├── README ├── TODO ├── acro.build ├── code ├── acro-examples.sty ├── acro.acronyms.code.tex ├── acro.aux.code.tex ├── acro.base.code.tex ├── acro.commands.code.tex ├── acro.definitions.code.tex ├── acro.formatting.code.tex ├── acro.interface.code.tex ├── acro.list.code.tex ├── acro.locale.code.tex ├── acro.pages.code.tex ├── acro.patch.code.tex ├── acro.pdfsupport.code.tex ├── acro.ppfixes.code.tex ├── acro.properties.code.tex ├── acro.start.code.tex ├── acro.sty ├── acro.templates.code.tex ├── acro.tools.code.tex ├── acro.upgrade.code.tex └── acro2.sty └── doc ├── acro-manual.cls ├── acro-manual.pdf ├── acro-manual.tex └── examples ├── acro.example.acflike.pdf ├── acro.example.acflike.tex ├── acro.example.basic.pdf ├── acro.example.basic.tex ├── acro.example.issue-109.pdf ├── acro.example.issue-109.tex ├── acro.example.issue-111.pdf ├── acro.example.issue-111.tex ├── acro.example.issue-119.pdf ├── acro.example.issue-119.tex ├── acro.example.issue-154.pdf ├── acro.example.issue-154.tex ├── acro.example.possessive.pdf ├── acro.example.possessive.tex ├── acro.example.texsx-505891.pdf ├── acro.example.texsx-505891.tex ├── acro.example.texsx-507726.pdf ├── acro.example.texsx-507726.tex ├── acro.example.texsx-513623.pdf ├── acro.example.texsx-513623.tex ├── acro.example.texsx-515295.pdf ├── acro.example.texsx-515295.tex ├── acro.example.texsx-542461.pdf ├── acro.example.texsx-542461.tex ├── acro.example.units.pdf └── acro.example.units.tex /LICENSE: -------------------------------------------------------------------------------- 1 | The LaTeX Project Public License 2 | =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 3 | 4 | LPPL Version 1.3c 2008-05-04 5 | 6 | Copyright 1999 2002-2008 LaTeX3 Project 7 | Everyone is allowed to distribute verbatim copies of this 8 | license document, but modification of it is not allowed. 9 | 10 | 11 | PREAMBLE 12 | ======== 13 | 14 | The LaTeX Project Public License (LPPL) is the primary license under 15 | which the LaTeX kernel and the base LaTeX packages are distributed. 16 | 17 | You may use this license for any work of which you hold the copyright 18 | and which you wish to distribute. This license may be particularly 19 | suitable if your work is TeX-related (such as a LaTeX package), but 20 | it is written in such a way that you can use it even if your work is 21 | unrelated to TeX. 22 | 23 | The section `WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE', 24 | below, gives instructions, examples, and recommendations for authors 25 | who are considering distributing their works under this license. 26 | 27 | This license gives conditions under which a work may be distributed 28 | and modified, as well as conditions under which modified versions of 29 | that work may be distributed. 30 | 31 | We, the LaTeX3 Project, believe that the conditions below give you 32 | the freedom to make and distribute modified versions of your work 33 | that conform with whatever technical specifications you wish while 34 | maintaining the availability, integrity, and reliability of 35 | that work. If you do not see how to achieve your goal while 36 | meeting these conditions, then read the document `cfgguide.tex' 37 | and `modguide.tex' in the base LaTeX distribution for suggestions. 38 | 39 | 40 | DEFINITIONS 41 | =========== 42 | 43 | In this license document the following terms are used: 44 | 45 | `Work' 46 | Any work being distributed under this License. 47 | 48 | `Derived Work' 49 | Any work that under any applicable law is derived from the Work. 50 | 51 | `Modification' 52 | Any procedure that produces a Derived Work under any applicable 53 | law -- for example, the production of a file containing an 54 | original file associated with the Work or a significant portion of 55 | such a file, either verbatim or with modifications and/or 56 | translated into another language. 57 | 58 | `Modify' 59 | To apply any procedure that produces a Derived Work under any 60 | applicable law. 61 | 62 | `Distribution' 63 | Making copies of the Work available from one person to another, in 64 | whole or in part. Distribution includes (but is not limited to) 65 | making any electronic components of the Work accessible by 66 | file transfer protocols such as FTP or HTTP or by shared file 67 | systems such as Sun's Network File System (NFS). 68 | 69 | `Compiled Work' 70 | A version of the Work that has been processed into a form where it 71 | is directly usable on a computer system. This processing may 72 | include using installation facilities provided by the Work, 73 | transformations of the Work, copying of components of the Work, or 74 | other activities. Note that modification of any installation 75 | facilities provided by the Work constitutes modification of the Work. 76 | 77 | `Current Maintainer' 78 | A person or persons nominated as such within the Work. If there is 79 | no such explicit nomination then it is the `Copyright Holder' under 80 | any applicable law. 81 | 82 | `Base Interpreter' 83 | A program or process that is normally needed for running or 84 | interpreting a part or the whole of the Work. 85 | 86 | A Base Interpreter may depend on external components but these 87 | are not considered part of the Base Interpreter provided that each 88 | external component clearly identifies itself whenever it is used 89 | interactively. Unless explicitly specified when applying the 90 | license to the Work, the only applicable Base Interpreter is a 91 | `LaTeX-Format' or in the case of files belonging to the 92 | `LaTeX-format' a program implementing the `TeX language'. 93 | 94 | 95 | 96 | CONDITIONS ON DISTRIBUTION AND MODIFICATION 97 | =========================================== 98 | 99 | 1. Activities other than distribution and/or modification of the Work 100 | are not covered by this license; they are outside its scope. In 101 | particular, the act of running the Work is not restricted and no 102 | requirements are made concerning any offers of support for the Work. 103 | 104 | 2. You may distribute a complete, unmodified copy of the Work as you 105 | received it. Distribution of only part of the Work is considered 106 | modification of the Work, and no right to distribute such a Derived 107 | Work may be assumed under the terms of this clause. 108 | 109 | 3. You may distribute a Compiled Work that has been generated from a 110 | complete, unmodified copy of the Work as distributed under Clause 2 111 | above, as long as that Compiled Work is distributed in such a way that 112 | the recipients may install the Compiled Work on their system exactly 113 | as it would have been installed if they generated a Compiled Work 114 | directly from the Work. 115 | 116 | 4. If you are the Current Maintainer of the Work, you may, without 117 | restriction, modify the Work, thus creating a Derived Work. You may 118 | also distribute the Derived Work without restriction, including 119 | Compiled Works generated from the Derived Work. Derived Works 120 | distributed in this manner by the Current Maintainer are considered to 121 | be updated versions of the Work. 122 | 123 | 5. If you are not the Current Maintainer of the Work, you may modify 124 | your copy of the Work, thus creating a Derived Work based on the Work, 125 | and compile this Derived Work, thus creating a Compiled Work based on 126 | the Derived Work. 127 | 128 | 6. If you are not the Current Maintainer of the Work, you may 129 | distribute a Derived Work provided the following conditions are met 130 | for every component of the Work unless that component clearly states 131 | in the copyright notice that it is exempt from that condition. Only 132 | the Current Maintainer is allowed to add such statements of exemption 133 | to a component of the Work. 134 | 135 | a. If a component of this Derived Work can be a direct replacement 136 | for a component of the Work when that component is used with the 137 | Base Interpreter, then, wherever this component of the Work 138 | identifies itself to the user when used interactively with that 139 | Base Interpreter, the replacement component of this Derived Work 140 | clearly and unambiguously identifies itself as a modified version 141 | of this component to the user when used interactively with that 142 | Base Interpreter. 143 | 144 | b. Every component of the Derived Work contains prominent notices 145 | detailing the nature of the changes to that component, or a 146 | prominent reference to another file that is distributed as part 147 | of the Derived Work and that contains a complete and accurate log 148 | of the changes. 149 | 150 | c. No information in the Derived Work implies that any persons, 151 | including (but not limited to) the authors of the original version 152 | of the Work, provide any support, including (but not limited to) 153 | the reporting and handling of errors, to recipients of the 154 | Derived Work unless those persons have stated explicitly that 155 | they do provide such support for the Derived Work. 156 | 157 | d. You distribute at least one of the following with the Derived Work: 158 | 159 | 1. A complete, unmodified copy of the Work; 160 | if your distribution of a modified component is made by 161 | offering access to copy the modified component from a 162 | designated place, then offering equivalent access to copy 163 | the Work from the same or some similar place meets this 164 | condition, even though third parties are not compelled to 165 | copy the Work along with the modified component; 166 | 167 | 2. Information that is sufficient to obtain a complete, 168 | unmodified copy of the Work. 169 | 170 | 7. If you are not the Current Maintainer of the Work, you may 171 | distribute a Compiled Work generated from a Derived Work, as long as 172 | the Derived Work is distributed to all recipients of the Compiled 173 | Work, and as long as the conditions of Clause 6, above, are met with 174 | regard to the Derived Work. 175 | 176 | 8. The conditions above are not intended to prohibit, and hence do not 177 | apply to, the modification, by any method, of any component so that it 178 | becomes identical to an updated version of that component of the Work as 179 | it is distributed by the Current Maintainer under Clause 4, above. 180 | 181 | 9. Distribution of the Work or any Derived Work in an alternative 182 | format, where the Work or that Derived Work (in whole or in part) is 183 | then produced by applying some process to that format, does not relax or 184 | nullify any sections of this license as they pertain to the results of 185 | applying that process. 186 | 187 | 10. a. A Derived Work may be distributed under a different license 188 | provided that license itself honors the conditions listed in 189 | Clause 6 above, in regard to the Work, though it does not have 190 | to honor the rest of the conditions in this license. 191 | 192 | b. If a Derived Work is distributed under a different license, that 193 | Derived Work must provide sufficient documentation as part of 194 | itself to allow each recipient of that Derived Work to honor the 195 | restrictions in Clause 6 above, concerning changes from the Work. 196 | 197 | 11. This license places no restrictions on works that are unrelated to 198 | the Work, nor does this license place any restrictions on aggregating 199 | such works with the Work by any means. 200 | 201 | 12. Nothing in this license is intended to, or may be used to, prevent 202 | complete compliance by all parties with all applicable laws. 203 | 204 | 205 | NO WARRANTY 206 | =========== 207 | 208 | There is no warranty for the Work. Except when otherwise stated in 209 | writing, the Copyright Holder provides the Work `as is', without 210 | warranty of any kind, either expressed or implied, including, but not 211 | limited to, the implied warranties of merchantability and fitness for a 212 | particular purpose. The entire risk as to the quality and performance 213 | of the Work is with you. Should the Work prove defective, you assume 214 | the cost of all necessary servicing, repair, or correction. 215 | 216 | In no event unless required by applicable law or agreed to in writing 217 | will The Copyright Holder, or any author named in the components of the 218 | Work, or any other party who may distribute and/or modify the Work as 219 | permitted above, be liable to you for damages, including any general, 220 | special, incidental or consequential damages arising out of any use of 221 | the Work or out of inability to use the Work (including, but not limited 222 | to, loss of data, data being rendered inaccurate, or losses sustained by 223 | anyone as a result of any failure of the Work to operate with any other 224 | programs), even if the Copyright Holder or said author or said other 225 | party has been advised of the possibility of such damages. 226 | 227 | 228 | MAINTENANCE OF THE WORK 229 | ======================= 230 | 231 | The Work has the status `author-maintained' if the Copyright Holder 232 | explicitly and prominently states near the primary copyright notice in 233 | the Work that the Work can only be maintained by the Copyright Holder 234 | or simply that it is `author-maintained'. 235 | 236 | The Work has the status `maintained' if there is a Current Maintainer 237 | who has indicated in the Work that they are willing to receive error 238 | reports for the Work (for example, by supplying a valid e-mail 239 | address). It is not required for the Current Maintainer to acknowledge 240 | or act upon these error reports. 241 | 242 | The Work changes from status `maintained' to `unmaintained' if there 243 | is no Current Maintainer, or the person stated to be Current 244 | Maintainer of the work cannot be reached through the indicated means 245 | of communication for a period of six months, and there are no other 246 | significant signs of active maintenance. 247 | 248 | You can become the Current Maintainer of the Work by agreement with 249 | any existing Current Maintainer to take over this role. 250 | 251 | If the Work is unmaintained, you can become the Current Maintainer of 252 | the Work through the following steps: 253 | 254 | 1. Make a reasonable attempt to trace the Current Maintainer (and 255 | the Copyright Holder, if the two differ) through the means of 256 | an Internet or similar search. 257 | 258 | 2. If this search is successful, then enquire whether the Work 259 | is still maintained. 260 | 261 | a. If it is being maintained, then ask the Current Maintainer 262 | to update their communication data within one month. 263 | 264 | b. If the search is unsuccessful or no action to resume active 265 | maintenance is taken by the Current Maintainer, then announce 266 | within the pertinent community your intention to take over 267 | maintenance. (If the Work is a LaTeX work, this could be 268 | done, for example, by posting to comp.text.tex.) 269 | 270 | 3a. If the Current Maintainer is reachable and agrees to pass 271 | maintenance of the Work to you, then this takes effect 272 | immediately upon announcement. 273 | 274 | b. If the Current Maintainer is not reachable and the Copyright 275 | Holder agrees that maintenance of the Work be passed to you, 276 | then this takes effect immediately upon announcement. 277 | 278 | 4. If you make an `intention announcement' as described in 2b. above 279 | and after three months your intention is challenged neither by 280 | the Current Maintainer nor by the Copyright Holder nor by other 281 | people, then you may arrange for the Work to be changed so as 282 | to name you as the (new) Current Maintainer. 283 | 284 | 5. If the previously unreachable Current Maintainer becomes 285 | reachable once more within three months of a change completed 286 | under the terms of 3b) or 4), then that Current Maintainer must 287 | become or remain the Current Maintainer upon request provided 288 | they then update their communication data within one month. 289 | 290 | A change in the Current Maintainer does not, of itself, alter the fact 291 | that the Work is distributed under the LPPL license. 292 | 293 | If you become the Current Maintainer of the Work, you should 294 | immediately provide, within the Work, a prominent and unambiguous 295 | statement of your status as Current Maintainer. You should also 296 | announce your new status to the same pertinent community as 297 | in 2b) above. 298 | 299 | 300 | WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE 301 | ====================================================== 302 | 303 | This section contains important instructions, examples, and 304 | recommendations for authors who are considering distributing their 305 | works under this license. These authors are addressed as `you' in 306 | this section. 307 | 308 | Choosing This License or Another License 309 | ---------------------------------------- 310 | 311 | If for any part of your work you want or need to use *distribution* 312 | conditions that differ significantly from those in this license, then 313 | do not refer to this license anywhere in your work but, instead, 314 | distribute your work under a different license. You may use the text 315 | of this license as a model for your own license, but your license 316 | should not refer to the LPPL or otherwise give the impression that 317 | your work is distributed under the LPPL. 318 | 319 | The document `modguide.tex' in the base LaTeX distribution explains 320 | the motivation behind the conditions of this license. It explains, 321 | for example, why distributing LaTeX under the GNU General Public 322 | License (GPL) was considered inappropriate. Even if your work is 323 | unrelated to LaTeX, the discussion in `modguide.tex' may still be 324 | relevant, and authors intending to distribute their works under any 325 | license are encouraged to read it. 326 | 327 | A Recommendation on Modification Without Distribution 328 | ----------------------------------------------------- 329 | 330 | It is wise never to modify a component of the Work, even for your own 331 | personal use, without also meeting the above conditions for 332 | distributing the modified component. While you might intend that such 333 | modifications will never be distributed, often this will happen by 334 | accident -- you may forget that you have modified that component; or 335 | it may not occur to you when allowing others to access the modified 336 | version that you are thus distributing it and violating the conditions 337 | of this license in ways that could have legal implications and, worse, 338 | cause problems for the community. It is therefore usually in your 339 | best interest to keep your copy of the Work identical with the public 340 | one. Many works provide ways to control the behavior of that work 341 | without altering any of its licensed components. 342 | 343 | How to Use This License 344 | ----------------------- 345 | 346 | To use this license, place in each of the components of your work both 347 | an explicit copyright notice including your name and the year the work 348 | was authored and/or last substantially modified. Include also a 349 | statement that the distribution and/or modification of that 350 | component is constrained by the conditions in this license. 351 | 352 | Here is an example of such a notice and statement: 353 | 354 | %% pig.dtx 355 | %% Copyright 2005 M. Y. Name 356 | % 357 | % This work may be distributed and/or modified under the 358 | % conditions of the LaTeX Project Public License, either version 1.3 359 | % of this license or (at your option) any later version. 360 | % The latest version of this license is in 361 | % http://www.latex-project.org/lppl.txt 362 | % and version 1.3 or later is part of all distributions of LaTeX 363 | % version 2005/12/01 or later. 364 | % 365 | % This work has the LPPL maintenance status `maintained'. 366 | % 367 | % The Current Maintainer of this work is M. Y. Name. 368 | % 369 | % This work consists of the files pig.dtx and pig.ins 370 | % and the derived file pig.sty. 371 | 372 | Given such a notice and statement in a file, the conditions 373 | given in this license document would apply, with the `Work' referring 374 | to the three files `pig.dtx', `pig.ins', and `pig.sty' (the last being 375 | generated from `pig.dtx' using `pig.ins'), the `Base Interpreter' 376 | referring to any `LaTeX-Format', and both `Copyright Holder' and 377 | `Current Maintainer' referring to the person `M. Y. Name'. 378 | 379 | If you do not want the Maintenance section of LPPL to apply to your 380 | Work, change `maintained' above into `author-maintained'. 381 | However, we recommend that you use `maintained', as the Maintenance 382 | section was added in order to ensure that your Work remains useful to 383 | the community even when you can no longer maintain and support it 384 | yourself. 385 | 386 | Derived Works That Are Not Replacements 387 | --------------------------------------- 388 | 389 | Several clauses of the LPPL specify means to provide reliability and 390 | stability for the user community. They therefore concern themselves 391 | with the case that a Derived Work is intended to be used as a 392 | (compatible or incompatible) replacement of the original Work. If 393 | this is not the case (e.g., if a few lines of code are reused for a 394 | completely different task), then clauses 6b and 6d shall not apply. 395 | 396 | 397 | Important Recommendations 398 | ------------------------- 399 | 400 | Defining What Constitutes the Work 401 | 402 | The LPPL requires that distributions of the Work contain all the 403 | files of the Work. It is therefore important that you provide a 404 | way for the licensee to determine which files constitute the Work. 405 | This could, for example, be achieved by explicitly listing all the 406 | files of the Work near the copyright notice of each file or by 407 | using a line such as: 408 | 409 | % This work consists of all files listed in manifest.txt. 410 | 411 | in that place. In the absence of an unequivocal list it might be 412 | impossible for the licensee to determine what is considered by you 413 | to comprise the Work and, in such a case, the licensee would be 414 | entitled to make reasonable conjectures as to which files comprise 415 | the Work. 416 | 417 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------- 2 | the ACRO package v3.8 2022/04/01 3 | 4 | Typeset Acronyms 5 | 6 | -------------------------------------------------------------------------- 7 | Clemens Niederberger 8 | Web: https://github.com/cgnieder/acro 9 | E-Mail: contact@mychemistry.eu 10 | -------------------------------------------------------------------------- 11 | Copyright 2012--2022 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.3c 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.3c or later is part of all distributions of LaTeX 19 | version 2008/05/04 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 code files: 26 | 27 | acro.sty 28 | acro2.sty 29 | acro-examples.sty 30 | 31 | The acro package consists of documentation files: 32 | 33 | README 34 | acro-manual.tex 35 | acro-manual.pdf 36 | acro-manual.cls 37 | 38 | The acro package consists of example files -- these should be placed in a 39 | folder examples/ in the same folder as acro-manual.pdf: 40 | 41 | acro.example.acflike.pdf, acro.example.acflike.tex 42 | acro.example.basic.pdf, acro.example.basic.tex 43 | acro.example.possessive.pdf, acro.example.possessive.tex 44 | acro.example.units.pdf, acro.example.units.tex 45 | acro.example.issue-109.pdf, acro.example.issue-109.tex 46 | acro.example.issue-111.pdf, acro.example.issue-111.tex 47 | acro.example.issue-119.pdf, acro.example.issue-119.tex 48 | acro.example.issue-154.pdf, acro.example.issue-154.tex 49 | acro.example.texsx-505891.pdf, acro.example.texsx-505891.tex 50 | acro.example.texsx-507726.pdf, acro.example.texsx-507726.tex 51 | acro.example.texsx-513623.pdf, acro.example.texsx-513623.tex 52 | acro.example.texsx-515295.pdf, acro.example.texsx-515295.tex 53 | acro.example.texsx-542461.pdf, acro.example.texsx-542461.tex 54 | 55 | -------------------------------------------------------------------------- 56 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | - solve issue #229 (inlude mechanism) 2 | - add gender property and extend article mechanism? 3 | 4 | willingly undocumented: 5 | - \acgobbletrail 6 | option 'acro/trailing/fnpct-check' 7 | \acfootnote 8 | - options 'acro/commands' 9 | - pdfstring templates and \acsimple 10 | - load-time options debug and final 11 | -------------------------------------------------------------------------------- /acro.build: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # the ACRO package 3 | # 4 | # Typeset Acronyms 5 | # 6 | # -------------------------------------------------------------------------- 7 | # Clemens Niederberger 8 | # Web: https://github.com/cgnieder/acro/ 9 | # E-Mail: contact@mychemistry.eu 10 | # -------------------------------------------------------------------------- 11 | # Copyright 2011--2020 Clemens Niederberger 12 | # 13 | # -------------------------------------------------------------------------- 14 | # this is a personal bash script to build the acro package 15 | # and very likely not of use for anybody else 16 | # 17 | # !! USE WITH CAUTION !! 18 | # 19 | # -------------------------------------------------------------------------- 20 | #!/bin/bash 21 | 22 | pkgname="acro" 23 | moduleext="code.tex" 24 | styname="$pkgname.sty" 25 | styoldname="${pkgname}2.sty" 26 | styexplname="${pkgname}-examples.sty" 27 | program="arara --verbose" 28 | manualfile="$pkgname-manual" 29 | zipname="$pkgname" 30 | 31 | build=true 32 | cleancode=false 33 | cleandoc=false 34 | cleanexamples=false 35 | cleanup=false 36 | createzip=false 37 | manual=false 38 | runmktexlsr=false 39 | update=false 40 | silent=false 41 | 42 | usage="script for buiding the $pkgname package 43 | 44 | ./$(basename "$0") [option(s) [value]] 45 | 46 | where valid options are: 47 | -b build sty file from modules (default: $build) 48 | -d deletes auxiliary files from a latex compilation 49 | allowed values: 'none', 'all', 'code', 'doc', 'examples' (default: 'none') 50 | -f name of manual file (without .tex) (default: '$manualfile') 51 | -h show this help 52 | -l run latex to (re-) create manual (default: $manual) 53 | -m run mktexlsr, only when used together with -u (default: $runmktexlsr) 54 | -n do nothing and exit 55 | -o output file for creating the style file (default: '$styname') 56 | -p program for building the manual (default: '$program') 57 | -s silent, avoid messages (default: $silent) 58 | -u update local tex repository (default: $update) 59 | -z create zip file for CTAN upload (default: $createzip)" 60 | 61 | # options: 62 | while [ -n "$1" ]; do 63 | case "$1" in 64 | -b|--build) 65 | case "$2" in 66 | true) 67 | shift ;; 68 | false) 69 | build=false 70 | shift ;; 71 | *) ;; 72 | esac ;; 73 | -d|--delete) 74 | case "$2" in 75 | none) 76 | cleanup=false ;; 77 | all) 78 | cleanup=true 79 | cleancode=true 80 | cleandoc=true 81 | cleanexamples=true ;; 82 | code) 83 | cleanup=true 84 | cleancode=true ;; 85 | doc) 86 | cleanup=true 87 | cleandoc=true ;; 88 | examples) 89 | cleanup=true 90 | cleanexamples=true ;; 91 | *) 92 | echo "invalid value '$2'" 93 | exit 1 ;; 94 | esac 95 | shift ;; 96 | -f|--file) 97 | manualfile="$2" 98 | shift ;; 99 | -h|--help) 100 | echo "$usage" 101 | exit 0 ;; 102 | -l|--latex) 103 | case "$2" in 104 | true) 105 | manual=true 106 | shift ;; 107 | false) 108 | manual=false 109 | shift ;; 110 | *) 111 | manual=true ;; 112 | esac ;; 113 | -m|--mktexlsr) 114 | case "$2" in 115 | true) 116 | runmktexlsr=true 117 | shift ;; 118 | false) 119 | runmktexlsr=false 120 | shift ;; 121 | *) 122 | runmktexlsr=true ;; 123 | esac ;; 124 | -n|--nothing) 125 | exit 0 ;; 126 | -o|--output) 127 | styname="$2" 128 | shift ;; 129 | -p|--program) 130 | program="$2" 131 | shift ;; 132 | -s|--silent) 133 | case "$2" in 134 | true) 135 | slient=true 136 | shift ;; 137 | false) 138 | silent=false 139 | shift ;; 140 | *) 141 | silent=true ;; 142 | esac ;; 143 | -u|--update) 144 | case "$2" in 145 | true) 146 | update=true 147 | shift ;; 148 | false) 149 | update=false 150 | shift ;; 151 | *) 152 | update=true ;; 153 | esac ;; 154 | -v|--version) 155 | zipname="${zipname}_v$2" 156 | shift ;; 157 | -z|--zip) 158 | case "$2" in 159 | true) 160 | createzip=true 161 | shift ;; 162 | false) 163 | createzip=false 164 | shift ;; 165 | *) 166 | createzip=true ;; 167 | esac ;; 168 | *) echo "unknown option '$1'" 169 | exit 1 ;; 170 | esac 171 | shift 172 | done 173 | 174 | if [ "$silent" == true ] ; then 175 | verbose=false 176 | else 177 | verbose=true 178 | fi 179 | 180 | START_DIR="${PWD}" 181 | DEV_DIR=~/LaTeX/dev 182 | SNAPSHOT_DIR=~/LaTeX/snapshots 183 | ACRO_DEV_DIR=${DEV_DIR}/$pkgname 184 | CODE_DIR=${ACRO_DEV_DIR}/code 185 | DOC_DIR=${ACRO_DEV_DIR}/doc 186 | EXAMPLES_DIR=${DOC_DIR}/examples 187 | TEXMFLOCAL_DIR=/usr/local/texlive/texmf-local 188 | LATEXLOCAL_DIR=${TEXMFLOCAL_DIR}/tex/latex/local 189 | BIBLOCAL_DIR=${TEXMFLOCAL_DIR}/bibtex/bib/local 190 | 191 | # files to be "cleaned": 192 | AUX_FILES="" 193 | if [ "$cleanup" == true ] ; then 194 | if [ "$cleancode" == true ] ; then 195 | AUX_FILES="${AUX_FILES} 196 | ${CODE_DIR}/*~" 197 | fi 198 | if [ "$cleandoc" == true ] ; then 199 | AUX_FILES="${AUX_FILES} 200 | ${DOC_DIR}/*~ 201 | ${DOC_DIR}/*synctex* 202 | ${DOC_DIR}/*.run.xml 203 | ${DOC_DIR}/*.aux 204 | ${DOC_DIR}/*.acr 205 | ${DOC_DIR}/*.xsim 206 | ${DOC_DIR}/*.log 207 | ${DOC_DIR}/*.out 208 | ${DOC_DIR}/*.bbl 209 | ${DOC_DIR}/*.bcf 210 | ${DOC_DIR}/*.bib 211 | ${DOC_DIR}/*.blg 212 | ${DOC_DIR}/*.idx 213 | ${DOC_DIR}/*.ilg 214 | ${DOC_DIR}/*.ind 215 | ${DOC_DIR}/*.tmp 216 | ${DOC_DIR}/*.toc 217 | ${DOC_DIR}/*.lof 218 | ${DOC_DIR}/*.lot" 219 | fi 220 | if [ "$cleanexamples" == true ] ; then 221 | AUX_FILES="${AUX_FILES} 222 | ${EXAMPLES_DIR}/*~ 223 | ${EXAMPLES_DIR}/*synctex* 224 | ${EXAMPLES_DIR}/*.run.xml 225 | ${EXAMPLES_DIR}/*.aux 226 | ${EXAMPLES_DIR}/*.acr 227 | ${EXAMPLES_DIR}/*.xsim 228 | ${EXAMPLES_DIR}/*.log 229 | ${EXAMPLES_DIR}/*.out 230 | ${EXAMPLES_DIR}/*.bbl 231 | ${EXAMPLES_DIR}/*.bcf 232 | ${EXAMPLES_DIR}/*.bib 233 | ${EXAMPLES_DIR}/*.blg 234 | ${EXAMPLES_DIR}/*.idx 235 | ${EXAMPLES_DIR}/*.ilg 236 | ${EXAMPLES_DIR}/*.ind 237 | ${EXAMPLES_DIR}/*.tmp 238 | ${EXAMPLES_DIR}/*.toc 239 | ${EXAMPLES_DIR}/*.lof 240 | ${EXAMPLES_DIR}/*.lot" 241 | fi 242 | fi 243 | 244 | 245 | if [ "$build" == true ] ; then 246 | if [ "$verbose" == true ] ; then 247 | echo "writing style file $styname ..." 248 | fi 249 | # change to the code directory 250 | cd ${CODE_DIR} 251 | # build sty file from modules: 252 | cat \ 253 | $pkgname.start.$moduleext \ 254 | $pkgname.base.$moduleext \ 255 | $pkgname.interface.$moduleext \ 256 | $pkgname.aux.$moduleext \ 257 | $pkgname.properties.$moduleext \ 258 | $pkgname.acronyms.$moduleext \ 259 | $pkgname.formatting.$moduleext \ 260 | $pkgname.ppfixes.$moduleext \ 261 | $pkgname.tools.$moduleext \ 262 | $pkgname.commands.$moduleext \ 263 | $pkgname.templates.$moduleext \ 264 | $pkgname.list.$moduleext \ 265 | $pkgname.pages.$moduleext \ 266 | $pkgname.locale.$moduleext \ 267 | $pkgname.pdfsupport.$moduleext \ 268 | $pkgname.patch.$moduleext \ 269 | $pkgname.definitions.$moduleext \ 270 | $pkgname.upgrade.$moduleext \ 271 | > $styname 272 | # append necessary end: 273 | echo -e "% finish package:\n\ 274 | \\hook_gput_code:nnn {enddocument} {acro} { \\\\acro_do_rerun: }\n\ 275 | %----------------------------------------------------------------------------\n\ 276 | \\\\file_input_stop:"\ 277 | >> $styname 278 | fi 279 | 280 | # build manual 281 | if [ "$manual" == true ] ; then 282 | cd ${DOC_DIR} 283 | if [ "$verbose" == true ] ; then 284 | echo "running '$program' on '$manualfile'..." 285 | fi 286 | $program $manualfile 287 | fi 288 | 289 | # remove temporary and auxiliary files 290 | if [ "$cleanup" == true ] ; then 291 | if [ "$verbose" == true ] ; then 292 | echo "deleting auxiliary files..." 293 | fi 294 | for file in ${AUX_FILES} 295 | do 296 | if [ ! -e "${file}" ]; then continue 297 | else 298 | if [ "$verbose" == true ] ; then 299 | echo "deleting file '${file}' ..." 300 | fi 301 | rm "${file}" 302 | fi 303 | done 304 | fi 305 | 306 | # move new sty file to local repo 307 | if [ "$update" == true ] ; then 308 | if [ "$verbose" == true ] ; then 309 | echo "updating texmf-local..." 310 | fi 311 | if [ ! -d "${LATEXLOCAL_DIR}/$pkgname" ]; then 312 | if [ "$verbose" == true ] ; then 313 | echo "creating directory '${LATEXLOCAL_DIR}/$pkgname' ..." 314 | fi 315 | mkdir ${LATEXLOCAL_DIR}/$pkgname 316 | fi 317 | cd ${CODE_DIR} 318 | cp $styname ${LATEXLOCAL_DIR}/$pkgname 319 | cp $styoldname ${LATEXLOCAL_DIR}/$pkgname 320 | cp $styexplname ${LATEXLOCAL_DIR}/$pkgname 321 | if [ "$runmktexlsr" == true ] ; then 322 | if [ "$verbose" == true ] ; then 323 | echo "running mktexlsr ..." 324 | fi 325 | mktexlsr 326 | fi 327 | fi 328 | 329 | if [ "$createzip" == true ] ; then 330 | if [ -f "${SNAPSHOT_DIR}/$pkgname/$zipname.zip" ] ; then 331 | rm ${SNAPSHOT_DIR}/$pkgname/$zipname.zip 332 | fi 333 | if [ "$verbose" == true ] ; then 334 | echo "creating zip archive $zipname.zip ..." 335 | fi 336 | cd ${ACRO_DEV_DIR} 337 | mkdir $pkgname/ 338 | mkdir $pkgname/examples 339 | cp ${CODE_DIR}/$styname $pkgname/ 340 | cp ${CODE_DIR}/$styoldname $pkgname/ 341 | cp ${CODE_DIR}/$styexplname $pkgname/ 342 | cp ${DOC_DIR}/$manualfile.tex $pkgname/ 343 | cp ${DOC_DIR}/$manualfile.pdf $pkgname/ 344 | cp ${DOC_DIR}/examples/$pkgname.example.*.tex $pkgname/examples/ 345 | cp ${DOC_DIR}/examples/$pkgname.example.*.pdf $pkgname/examples/ 346 | cp README $pkgname/ 347 | zip -r $zipname.zip $pkgname/ 348 | rm -r $pkgname/ 349 | if [ "$verbose" == true ] ; then 350 | echo "moving zip archive $zipname.zip ..." 351 | fi 352 | mv $zipname.zip ${SNAPSHOT_DIR}/$pkgname/$zipname.zip 353 | fi 354 | 355 | cd ${START_DIR} 356 | 357 | exit 0 358 | -------------------------------------------------------------------------------- /code/acro-examples.sty: -------------------------------------------------------------------------------- 1 | \RequirePackage{acro} 2 | \ProvidesPackage{acro-examples}[\csname c_acro_date_tl\endcsname\space v0.1 3 | example definitions with acro (CN)] 4 | 5 | \DeclareAcronym{afaik}{ 6 | short = AFAIK , 7 | long = as far as I know 8 | } 9 | \DeclareAcronym{afk}{ 10 | short = AFK , 11 | long = away from keyboard 12 | } 13 | \DeclareAcronym{asap}{ 14 | short = ASAP , 15 | long = as soon as possible 16 | } 17 | \DeclareAcronym{ba}{ 18 | short = BA , 19 | long = Bachelor of Arts 20 | } 21 | \DeclareAcronym{bnd}{ 22 | short = BND , 23 | long = Bundesnachrichtendienst 24 | } 25 | \DeclareAcronym{bs}{ 26 | short = BS , 27 | long = Bachelor of Science 28 | } 29 | \DeclareAcronym{cd}{ 30 | short = CD , 31 | long = compact disc 32 | } 33 | \DeclareAcronym{cdu}{ 34 | short = CDU , 35 | long = Christlich-Demokratische Union 36 | } 37 | \DeclareAcronym{ceo}{ 38 | short = CEO , 39 | long = chief executive officer 40 | } 41 | \DeclareAcronym{cia}{ 42 | short = CIA , 43 | long = Central Intelligence Agency 44 | } 45 | \DeclareAcronym{csu}{ 46 | short = CSU , 47 | long = Christlich-Soziale Union 48 | } 49 | \DeclareAcronym{ctan}{ 50 | short = CTAN , 51 | long = Comprehensive \TeX\ Archive Network 52 | } 53 | \DeclareAcronym{dea}{ 54 | short = DEA , 55 | long = Drug Enforcement Administration 56 | } 57 | \DeclareAcronym{diy}{ 58 | short = DIY , 59 | long = do it yourself 60 | } 61 | \DeclareAcronym{dpa}{ 62 | short = DPA , 63 | long = Deutsche Presseagentur 64 | } 65 | \DeclareAcronym{eta}{ 66 | short = ETA , 67 | long = estimated time of arrival 68 | } 69 | \DeclareAcronym{fbi}{ 70 | short = FBI , 71 | long = Federal Bureau of Investigation 72 | } 73 | \acroifpropertyTF{short-definite}{ 74 | \DeclareAcronym{hadopi}{ 75 | short = HADOPI , 76 | long = Haute Autorité pour la diffusion des œuvres et la protection des 77 | droits sur l’Internet , 78 | short-definite = l'\nospace , 79 | long-definite = la 80 | } 81 | }{ 82 | \DeclareAcronym{hadopi}{ 83 | short = HADOPI , 84 | long = Haute Autorité pour la diffusion des œuvres et la protection des 85 | droits sur l’Internet 86 | } 87 | } 88 | \DeclareAcronym{iirc}{ 89 | short = IIRC , 90 | long = if I remember correctly 91 | } 92 | \DeclareAcronym{imho}{ 93 | short = IMHO , 94 | long = in my humble opinion 95 | } 96 | \DeclareAcronym{jpg}{ 97 | short = JPEG , 98 | sort = jpeg , 99 | alt = JPG , 100 | long = joint photographic experts group 101 | } 102 | \DeclareAcronym{ksk}{ 103 | short = KSK , 104 | long = Kommando Spezialkräfte 105 | } 106 | \DeclareAcronym{lol}{ 107 | short = LOL , 108 | long = loughing out loud 109 | } 110 | \DeclareAcronym{lppl}{ 111 | short = LPPL , 112 | long = \LaTeX\ Project Public License 113 | } 114 | \DeclareAcronym{ma}{ 115 | short = MA , 116 | long = Master of Arts 117 | } 118 | \DeclareAcronym{nato}{ 119 | short = NATO , 120 | long = North Atlantic Treaty Organization 121 | } 122 | \DeclareAcronym{nsa}{ 123 | short = NSA , 124 | long = National Security Agency 125 | } 126 | \DeclareAcronym{omg}{ 127 | short = OMG , 128 | long = oh my god 129 | } 130 | \DeclareAcronym{otan}{ 131 | short = OTAN , 132 | long = Organisation du Traité de l'Atlantique Nord 133 | } 134 | \DeclareAcronym{pdf}{ 135 | short = PDF , 136 | long = portable document format 137 | } 138 | \DeclareAcronym{png}{ 139 | short = PNG , 140 | long = portable network graphics 141 | } 142 | \DeclareAcronym{rofl}{ 143 | short = ROFL , 144 | long = rolling on the floor laughing 145 | } 146 | \DeclareAcronym{spd}{ 147 | short = SPD , 148 | long = Sozialdemokratische Partei Deutschlands 149 | } 150 | \DeclareAcronym{tiff}{ 151 | short = TIFF , 152 | long = tagged image file format 153 | } 154 | \DeclareAcronym{ufo}{ 155 | short = UFO , 156 | long = unidentified flying object , 157 | long-indefinite = an 158 | } 159 | \DeclareAcronym{yolo}{ 160 | short = YOLO , 161 | long = you only live once 162 | } 163 | 164 | \endinput 165 | 166 | 2021/01/13 - first version 167 | -------------------------------------------------------------------------------- /code/acro.acronyms.code.tex: -------------------------------------------------------------------------------- 1 | \AcroModule{acronyms}{define acronyms} 2 | 3 | % -------------------------------------------------------------------------- 4 | \msg_new:nnn {acro} {undefined} 5 | { 6 | You've~ requested~ acronym~ `#1'~ \msg_line_context: \ but~ you~ 7 | apparently~ haven't~ defined~ it,~ yet! \\ 8 | Maybe~ you've~ misspelled~ `#1'? 9 | } 10 | 11 | \msg_new:nnn {acro} {mandatory} 12 | { 13 | You~ forgot~ to~ set~ the~ mandatory~ property~ `#2'~ for~ acronym~ 14 | `#1'~ \msg_line_context: 15 | } 16 | 17 | % -------------------------------------------------------------------------- 18 | % short and long list: 19 | \tl_new:N \l__acro_short_tl 20 | \tl_new:N \l__acro_long_tl 21 | 22 | \cs_new_protected:Npn \acro_list_add:nn #1#2 23 | { 24 | \clist_map_inline:nn {#2} 25 | { 26 | \tl_put_right:cn {l__acro_#1_tl} {{##1}} 27 | \cs_set:cpn {____acro_#1::##1____:} {} 28 | } 29 | } 30 | 31 | \cs_new_protected:Npn \acro_list_map:nn #1#2 32 | { \tl_map_inline:cn {l__acro_#1_tl} {#2} } 33 | 34 | \prg_new_conditional:Npnn \acro_if_short:n #1 {p,T,F,TF} 35 | { 36 | \cs_if_exist:cTF {____acro_short::#1____:} 37 | { \prg_return_true: } 38 | { \prg_return_false: } 39 | } 40 | 41 | \prg_new_conditional:Npnn \acro_if_long:n #1 {p,T,F,TF} 42 | { 43 | \cs_if_exist:cTF {____acro_long::#1____:} 44 | { \prg_return_true: } 45 | { \prg_return_false: } 46 | } 47 | 48 | % -------------------------------------------------------------------------- 49 | % define necessary properties: 50 | % short and long properties: 51 | \acro_list_add:nn {short} {short,alt} 52 | \acro_list_add:nn {long} {long,foreign,single,extra,list} 53 | 54 | % meta information: 55 | \DeclareAcroProperty*!{id} 56 | \DeclareAcroProperty ?{used} 57 | \DeclareAcroProperty |{usage} 58 | \DeclareAcroProperty |{pages} 59 | \DeclareAcroProperty |{barriers} 60 | \DeclareAcroProperty* {label} 61 | 62 | % main properties: 63 | \DeclareAcroProperty !{short} 64 | \DeclareAcroProperty {alt} 65 | \DeclareAcroProperty !{long} 66 | 67 | \DeclareAcroProperty{uselist} 68 | \DeclareAcroProperty{preset} 69 | 70 | % sorting, indexing, ... : 71 | \DeclareAcroPropertyAlias {sort} {short} 72 | \DeclareAcroProperty {index} 73 | \DeclareAcroProperty?{no-index} 74 | \DeclareAcroPropertyAlias {index-sort} {sort} 75 | \DeclareAcroProperty {index-cmd} 76 | \DeclareAcroProperty {tag} 77 | \DeclareAcroProperty {cite} 78 | \DeclareAcroProperty {before-citation} 79 | \DeclareAcroPropertyAlias {pdfstring} {short} 80 | \DeclareAcroProperty {pdfcomment} 81 | 82 | % locale: 83 | \DeclareAcroProperty>{foreign} 84 | \DeclareAcroProperty {foreign-babel} 85 | \DeclareAcroProperty {foreign-locale} 86 | 87 | % additional properties: 88 | \DeclareAcroProperty {single} 89 | \DeclareAcroPropertyAlias {list} {long} 90 | \DeclareAcroPropertyAlias {first-long} {long} 91 | \DeclareAcroProperty {extra} 92 | \DeclareAcroProperty {post} 93 | \DeclareAcroProperty {long-post} 94 | \DeclareAcroProperty {first-style} 95 | \DeclareAcroProperty {subsequent-style} 96 | \DeclareAcroProperty {single-style} 97 | 98 | % formatting: 99 | \DeclareAcroProperty {format} 100 | \DeclareAcroPropertyAlias {short-format} {format} 101 | \DeclareAcroProperty {alt-format} 102 | \DeclareAcroPropertyAlias {long-format} {format} 103 | \DeclareAcroPropertyAlias {first-long-format} {long-format} 104 | \DeclareAcroProperty {foreign-format} 105 | % \DeclareAcroProperty {single-format} 106 | \DeclareAcroProperty {list-format} 107 | \DeclareAcroProperty {extra-format} 108 | 109 | % Accessibility: 110 | \acro_list_map:nn {short} 111 | { 112 | \DeclareAcroPropertyAlias {#1-acc} {#1} 113 | \acro_list_add:nn {short} {#1-acc} 114 | } 115 | 116 | \acro_list_map:nn {long} 117 | { 118 | \DeclareAcroPropertyAlias {#1-acc} {#1} 119 | \acro_list_add:nn {long} {#1-acc} 120 | } 121 | 122 | % -------------------------------------------------------------------------- 123 | % use id as short entry: 124 | \bool_new:N \g__acro_use_id_bool 125 | 126 | \keys_define:nn {acro} 127 | { 128 | use-id-as-short .choice: , 129 | use-id-as-short / true .code:n = 130 | \bool_gset_true:N \g__acro_use_id_bool , 131 | use-id-as-short / false .code:n = 132 | \bool_gset_false:N \g__acro_use_id_bool , 133 | use-id-as-short .default:n = true 134 | } 135 | 136 | % -------------------------------------------------------------------------- 137 | % declaration of acronyms: 138 | \seq_new:N \g_acro_acronyms_seq 139 | 140 | \tl_new:N \l__acro_first_style_tl 141 | 142 | \acro_attribute_new:n {acronyms} 143 | 144 | \keys_define:nn {acro} 145 | { 146 | first-style .tl_set:N = \l__acro_first_style_tl , 147 | first-style .initial:n = long-short , 148 | subsequent-style .tl_set:N = \l__acro_subsequent_tl , 149 | subsequent-style .initial:n = short 150 | } 151 | 152 | \cs_new_protected:Npn \acro_declare_acronym:nn #1#2 153 | { \acro_case_insensitive:Nn \__acro_declare_acronym:nn {#1} {#2} } 154 | 155 | % #1: id 156 | % #2: properties 157 | \cs_new_protected:Npn \__acro_declare_acronym:nn #1#2 158 | { 159 | \newcounter {g@acro@#1@int} 160 | \seq_new:c {g__acro_#1_pages_seq} 161 | \seq_new:c {g__acro_#1_barriers_seq} 162 | \acro_at_begin_document:n 163 | { 164 | \intarray_new:cn 165 | {g__acro_#1_barriers_intarray} 166 | { \g_acro_barrier_total_int } 167 | } 168 | \seq_gput_right:Nn \g_acro_acronyms_seq {#1} 169 | \acro_attribute_set:nnn {acronyms} {#1} {} 170 | % set defaults: 171 | \__acro_set_article_defaults:n {#1} 172 | % set user input: 173 | \acro_properties_set:nn {#1} {#2} 174 | % set defaults which must not be overwritten: 175 | \acro_property_set:nnn {#1} {usage} {0} 176 | \bool_lazy_and:nnT 177 | { \g__acro_use_id_bool } 178 | { !\acro_property_if_set_p:nn {#1} {short} } 179 | { \acro_property_set:nnn {#1} {short} {#1} } 180 | \acro_property_set:nnn {#1} {id} {#1} 181 | \acro_preset_set_properties:n {#1} 182 | \acro_property_set_aliases:n {#1} 183 | % check mandatory properties: 184 | \acro_property_foreach_mandatory:n 185 | { 186 | \acro_property_if_set:nnF {#1} {##1} 187 | { \msg_error:nnnn {acro} {mandatory} {#1} {##1} } 188 | } 189 | % set endings: 190 | \acro_set_endings:n {#1} 191 | \acro_at_end_document:n 192 | { 193 | \acro_property_set:nnx {#1} {usage} { \arabic {g@acro@#1@int} } 194 | \acro_set_barriers:n {#1} 195 | } 196 | } 197 | 198 | \prg_new_conditional:Npnn \acro_if_defined:n #1 {p,T,F,TF} 199 | { 200 | \acro_attribute_if_set:neTF {acronyms} 201 | { \acro_case_insensitive:n {#1} } 202 | { \prg_return_true: } 203 | { \prg_return_false: } 204 | } 205 | 206 | \prg_new_protected_conditional:Npnn \__acro_uselist_if_used:n #1 {T,F,TF} 207 | { 208 | \acro_property_if_set:nnTF {#1} {uselist} 209 | { 210 | \clist_set:Nx \l__acro_tmpa_clist 211 | { \acro_property_get:nn {#1} {uselist} } 212 | \clist_clear:N \l__acro_tmpb_clist 213 | \clist_map_inline:Nn \l__acro_tmpa_clist 214 | { 215 | \acro_boolean_property_if:nnT {##1} {used} 216 | { \clist_put_right:Nn \l__acro_tmpb_clist {##1} } 217 | } 218 | \tl_if_eq:VVTF \l__acro_tmpa_clist \l__acro_tmpb_clist 219 | { \prg_return_true: } 220 | { \prg_return_false: } 221 | } 222 | { \prg_return_false: } 223 | } 224 | 225 | \cs_new_protected:Npn \acro_check_definition:nT #1#2 226 | { 227 | \acro_if_defined:nTF {#1} 228 | { 229 | \acro_boolean_property_if:nnF {#1} {used} 230 | { \__acro_uselist_if_used:nT {#1} { \__acro_use:n {#1} } } 231 | #2 232 | } 233 | { \acro_acronym_undefined:n {#1} } 234 | } 235 | 236 | \cs_new_protected:Npn \acro_acronym_undefined:n #1 237 | { \msg_error:nnn {acro} {undefined} {#1} } 238 | 239 | % -------------------------------------------------------------------------- 240 | % use and reset: 241 | \bool_new:N \l__acro_use_bool 242 | \bool_set_true:N \l__acro_use_bool 243 | 244 | \cs_new_protected:Npn \acro_map_acronyms:n #1 245 | { \seq_map_inline:Nn \g_acro_acronyms_seq {#1} } 246 | 247 | \cs_new:Npn \acro_map_break: { \seq_map_break: } 248 | \cs_new:Npn \acro_map_break:n { \seq_map_break:n } 249 | 250 | \cs_new_protected:Npn \acro_use_false: 251 | { \bool_set_false:N \l__acro_use_bool } 252 | 253 | \cs_new_protected:Npn \__acro_use:n #1 254 | { 255 | \bool_if:NT \l__acro_use_bool 256 | { 257 | \acro_property_set:nnn {#1} {used} {true} 258 | \acro_step:n {#1} 259 | \acro_record_barrier:n {#1} 260 | } 261 | } 262 | 263 | \cs_new_protected:Npn \acro_use:n #1 264 | { \clist_map_inline:nn {#1} { \__acro_use:n {##1} } } 265 | \cs_generate_variant:Nn \acro_use:n {e} 266 | 267 | \cs_new_protected:Npn \acro_use_all: 268 | { \seq_map_inline:Nn \g_acro_acronyms_seq { \__acro_use:n {##1} } } 269 | 270 | \cs_new_protected:Npn \__acro_reset:n #1 271 | { \acro_property_set:nnn {#1} {used} {false} } 272 | 273 | \cs_new_protected:Npn \acro_reset:n #1 274 | { \clist_map_inline:nn {#1} { \__acro_reset:n {##1} } } 275 | 276 | \cs_new_protected:Npn \acro_reset_all: 277 | { \seq_map_inline:Nn \g_acro_acronyms_seq { \__acro_reset:n {##1} } } 278 | 279 | \cs_new_protected:Npn \acro_switch_off: 280 | { \bool_set_false:N \l__acro_use_bool } 281 | 282 | \cs_new_protected:Npn \acro_switch_on: 283 | { \bool_set_true:N \l__acro_use_bool } 284 | 285 | % -------------------------------------------------------------------------- 286 | % check for tags: 287 | % #1: id 288 | % #2: tag 289 | \prg_new_protected_conditional:Npnn \acro_tag_if:nn #1#2 {T,F,TF} 290 | { 291 | \clist_set:Ne \l__acro_tmpa_clist { \acro_property_get:nn {#1} {tag} } 292 | \clist_if_in:NnTF \l__acro_tmpa_clist {#2} 293 | { \prg_return_true: } 294 | { \prg_return_false: } 295 | } 296 | \prg_generate_conditional_variant:Nnn \acro_tag_if:nn {en} {T,F,TF} 297 | 298 | % -------------------------------------------------------------------------- 299 | \AcroModuleEnd 300 | -------------------------------------------------------------------------------- /code/acro.aux.code.tex: -------------------------------------------------------------------------------- 1 | \AcroModule{aux}{usage of LaTeX's aux files} 2 | 3 | 4 | % this is still true \AtBeginDocument: 5 | \prg_new_conditional:Npnn \acro_if_preamble: {p,T,F,TF} 6 | { 7 | \cs_if_eq:NNTF \@onlypreamble \@notprerr 8 | { \prg_return_false: } 9 | { \prg_return_true: } 10 | } 11 | 12 | \cs_new_protected:Npn \ACRO #1 { \use:c {__acro_aux_#1:} } 13 | 14 | \cs_new_protected:Npn \__acro_auxlist_field_new:cpn #1 15 | { \cs_new_protected:cpn {__acro_aux_#1:} } 16 | 17 | \cs_new_protected:Npn \acro_auxlist_write_entry:nn #1#2 18 | { 19 | \acro_if_preamble:F 20 | { 21 | \acro_write_to_aux:x 22 | { \token_to_str:N \ACRO {#1} #2 } 23 | } 24 | } 25 | 26 | \cs_new_protected:Npn \acro_auxlist_to_aux:nn #1#2 27 | { \acro_write_to_aux:x { \token_to_str:N \ACRO {#1} #2 } } 28 | 29 | \tl_new:N \l__acro_mdfive_hash_tl 30 | 31 | \cs_new_protected:Npn \acro_write_to_aux:n #1 32 | { \legacy_if:nT {@filesw} { \iow_now:Nn \@auxout {#1} } } 33 | \cs_generate_variant:Nn \acro_write_to_aux:n {x} 34 | 35 | % ---------------------------------------------------------------------------- 36 | % define list: 37 | % #1: name 38 | \cs_new_protected:Npn \__acro_auxlist_new:n #1 39 | { 40 | % entries collected during the run: 41 | \seq_new:c {g__acro_auxlist_#1_seq} 42 | % entries read from the auxfile: 43 | \seq_new:c {g__acro_auxlist_recorded_#1_seq} 44 | \acro_attribute_new:n {#1} 45 | \__acro_auxlist_field_new:cpn {#1} ##1 46 | { 47 | \tl_if_blank:nF {##1} 48 | { 49 | \seq_gput_right:cx {g__acro_auxlist_#1_seq} 50 | { \tl_to_str:n {##1} } 51 | \seq_map_inline:cn {g__acro_auxlist_#1_seq} 52 | { \acro_attribute_set:nnn {#1} {####1} {} } 53 | } 54 | } 55 | \acro_at_begin_document:n 56 | { 57 | \seq_gclear:c {g__acro_auxlist_recorded_#1_seq} 58 | \seq_set_eq:Nc \l__acro_tmpa_seq {g__acro_auxlist_#1_seq} 59 | \seq_map_inline:Nn \l__acro_tmpa_seq 60 | { 61 | \str_set:Nn \l__acro_tmpa_str {##1} 62 | \seq_gput_right:cV {g__acro_auxlist_recorded_#1_seq} \l__acro_tmpa_str 63 | } 64 | \seq_gremove_duplicates:c {g__acro_auxlist_recorded_#1_seq} 65 | } 66 | } 67 | 68 | % add to or remove from list: 69 | % #1: name 70 | % #2: entry 71 | \cs_new_protected:Npn \__acro_auxlist_add:nn #1#2 72 | { 73 | \str_set:Nn \l__acro_tmpa_str {#2} 74 | \acro_attribute_set:nnn {#1} {#2} {} 75 | \seq_if_in:cVT {g__acro_auxlist_#1_seq} \l__acro_tmpa_str 76 | { \seq_gremove_all:cV {g__acro_auxlist_#1_seq} \l__acro_tmpa_str } 77 | % \acro_auxlist_write_entry:nn {#1} {{#2}} 78 | \seq_gput_right:cV {g__acro_auxlist_#1_seq} \l__acro_tmpa_str 79 | \seq_gremove_duplicates:c {g__acro_auxlist_#1_seq} 80 | } 81 | \cs_generate_variant:Nn \__acro_auxlist_add:nn {nx} 82 | 83 | % #1: name 84 | % #2: entry 85 | \cs_new_protected:Npn \__acro_auxlist_remove:nn #1#2 86 | { 87 | \str_set:Nn \l__acro_tmpa_str {#2} 88 | \acro_attribute_if_set:nnT {#1} {#2} 89 | { \acro_attribute_unset:nn {#1} {#2} } 90 | \seq_if_in:cVT {g__acro_auxlist_#1_seq} \l__acro_tmpa_str 91 | { \seq_gremove_all:cV {g__acro_auxlist_#1_seq} \l__acro_tmpa_str } 92 | } 93 | \cs_generate_variant:Nn \__acro_auxlist_remove:nn {nx} 94 | 95 | % check if in list: 96 | % #1: name 97 | % #2: entry 98 | \prg_new_conditional:Npnn \__acro_auxlist_if_in:nn #1#2 {p,T,F,TF} 99 | { 100 | \acro_attribute_if_set:nnTF {#1} {#2} 101 | { \prg_return_true: } 102 | { \prg_return_false: } 103 | } 104 | \prg_generate_conditional_variant:Nnn \__acro_auxlist_if_in:nn {nx} {T,TF} 105 | 106 | \bool_new:N \l__acro_auxlists_clear_bool 107 | \cs_new_protected:Npn \acro_auxlists_clear: 108 | { \bool_set_true:N \l__acro_auxlists_clear_bool } 109 | 110 | 111 | \cs_new_protected:Npn \__acro_get_string_from_property_seq:NN #1#2 112 | { 113 | \prop_clear:N \l__acro_tmpa_prop 114 | \seq_clear:N \l__acro_tmpa_seq 115 | \seq_map_inline:Nn #1 116 | { 117 | \__acro_get_aux_entry:nNN {##1} 118 | \l__acro_tmpa_tl 119 | \l__acro_tmpb_tl 120 | \prop_put:NVV \l__acro_tmpa_prop \l__acro_tmpa_tl \l__acro_tmpb_tl 121 | } 122 | \prop_map_inline:Nn \l__acro_tmpa_prop 123 | { \seq_put_right:Nn \l__acro_tmpa_seq {##1:##2} } 124 | \acro_seq_sort:N \l__acro_tmpa_seq 125 | \str_set:Nx #2 { \seq_use:Nn \l__acro_tmpa_seq {} } 126 | } 127 | \cs_generate_variant:Nn \__acro_get_string_from_property_seq:NN {c} 128 | 129 | % update list (should be used inside \acro_at_end_document:n): 130 | % #1: name 131 | \cs_new_protected:Npn \__acro_auxlist_update:n #1 132 | { 133 | \__acro_get_string_from_property_seq:cN 134 | {g__acro_auxlist_#1_seq} 135 | \l__acro_tmpa_str 136 | \__acro_get_string_from_property_seq:cN 137 | {g__acro_auxlist_recorded_#1_seq} 138 | \l__acro_tmpb_str 139 | \str_if_eq:NNF \l__acro_tmpa_str \l__acro_tmpb_str 140 | { \acro_rerun:n {property} } 141 | \bool_if:NF \l__acro_auxlists_clear_bool 142 | { 143 | \seq_map_inline:cn {g__acro_auxlist_#1_seq} 144 | { \acro_auxlist_write_entry:nn {#1} {{##1}} } 145 | } 146 | } 147 | 148 | % loop over list: 149 | % #1: name 150 | % #2: code 151 | \cs_new_protected:Npn \__acro_auxlist_foreach_entry:nn #1#2 152 | { \seq_map_inline:cn {g__acro_auxlist_recorded_#1_seq} {#2} } 153 | 154 | \cs_new_protected:Npn \__acro_auxlist_foreach_new_entry:nn #1#2 155 | { \seq_map_inline:cn {g__acro_auxlist_#1_seq} {#2} } 156 | 157 | % length of a list: 158 | % #1: name 159 | \cs_new:Npn \__acro_auxlist_count:n #1 160 | { \seq_count:c {g__acro_auxlist_recorded_#1_seq} } 161 | 162 | % item of a list: 163 | % #1: name 164 | % #2: integer 165 | \cs_new:Npn \__acro_auxlist_item:nn #1#2 166 | { \seq_item:cn {g__acro_auxlist_recorded_#1_seq} {#2} } 167 | 168 | % ---------------------------------------------------------------------------- 169 | \AcroModuleEnd 170 | -------------------------------------------------------------------------------- /code/acro.base.code.tex: -------------------------------------------------------------------------------- 1 | \AcroModule{base}{basic functionality of the package} 2 | 3 | % -------------------------------------------------------------------------- 4 | % variants of kernel functions: 5 | \cs_generate_variant:Nn \bool_lazy_any:nTF {e} 6 | \cs_generate_variant:Nn \bool_lazy_all:nTF {e} 7 | \cs_generate_variant:Nn \seq_gset_split:Nnn {cVx} 8 | \cs_generate_variant:Nn \seq_use:Nn {cV} 9 | \cs_generate_variant:Nn \seq_set_split:Nnn {Nnx} 10 | \cs_generate_variant:Nn \seq_if_in:NnTF {Ne} 11 | \cs_generate_variant:Nn \seq_if_in:NnF {ceF} 12 | \cs_generate_variant:Nn \seq_gremove_all:Nn {cV} 13 | \cs_generate_variant:Nn \seq_put_right:Nn {Ne} 14 | \cs_generate_variant:Nn \seq_gput_right:Nn {Ne,ce} 15 | \cs_generate_variant:Nn \seq_set_split:Nnn {Nne} 16 | \cs_generate_variant:Nn \clist_if_empty:nTF {e} 17 | \cs_generate_variant:Nn \clist_item:nn {e} 18 | \cs_generate_variant:Nn \clist_count:n {e} 19 | \cs_generate_variant:Nn \int_set:Nn {Nx} 20 | \cs_generate_variant:Nn \tl_set:Nn {Ne} 21 | \cs_generate_variant:Nn \tl_remove_all:Nn {NV} 22 | \cs_generate_variant:Nn \tl_remove_once:Nn {NV} 23 | \cs_generate_variant:Nn \tl_if_in:NnF {NV} 24 | \cs_generate_variant:Nn \tl_if_eq:nnTF {VV} 25 | \cs_generate_variant:Nn \tl_put_right:Nn {Ne} 26 | \cs_generate_variant:Nn \clist_set:Nn {Ne} 27 | \cs_generate_variant:Nn \str_if_eq:nnT {x} 28 | \cs_generate_variant:Nn \str_foldcase:n {e} 29 | \cs_generate_variant:Nn \str_lowercase:n {e} 30 | \cs_generate_variant:Nn \msg_error:nnnnn {nnnxx} 31 | \cs_generate_variant:Nn \msg_warning:nn {nV} 32 | \cs_generate_variant:Nn \msg_error:nnnn {nne} 33 | \cs_generate_variant:Nn \prg_new_conditional:Npnn {c} 34 | \cs_generate_variant:Nn \file_get_mdfive_hash:nN {V} 35 | \cs_generate_variant:Nn \iow_open:Nn {NV} 36 | \cs_generate_variant:Nn \use_ii:nn {ne} 37 | \cs_generate_variant:Nn \keys_set:nn {nV} 38 | 39 | % -------------------------------------------------------------------------- 40 | \prg_new_conditional:Npnn \acro_class_if_loaded:n #1 {p,T,F,TF} 41 | { 42 | \cs_if_exist:cTF {ver@#1.cls} 43 | { \prg_return_true: } 44 | { \prg_return_false: } 45 | } 46 | 47 | \prg_new_conditional:Npnn \acro_if_komascript: {p,T,F,TF} 48 | { 49 | \cs_if_exist:NTF \KOMAClassName 50 | { \prg_return_true: } 51 | { \prg_return_false: } 52 | } 53 | 54 | % -------------------------------------------------------------------------- 55 | % attributes instead of property lists: 56 | \msg_new:nnn {acro} {attribute-not-set} 57 | { The~ attribute~ `#1'~ is~ not~ set~ \msg_line_context: } 58 | 59 | \msg_new:nnn {acro} {attribute-defined} 60 | { The~ attribute~ `#1'~ is~ already~ defined~ \msg_line_context: } 61 | 62 | \msg_new:nnn {acro} {attribute-undefined} 63 | { The~ attribute~ `#1'~ is~ not~ yet~ defined~ \msg_line_context: } 64 | 65 | \prg_new_conditional:Npnn \acro_attribute_if_exist:n #1 {p,T,F,TF} 66 | { 67 | \cs_if_exist:cTF {____acro_attribute_main_ \tl_to_str:n {#1} :} 68 | { \prg_return_true: } 69 | { \prg_return_false: } 70 | } 71 | 72 | % #1: attribute 73 | \cs_new_protected:Npn \acro_attribute_new:n #1 74 | { 75 | \acro_attribute_if_exist:nTF {#1} 76 | { \msg_error:nnn {acro} {attribute-defined} {#1} } 77 | { \cs_gset:cpx {____acro_attribute_main_ \tl_to_str:n {#1} :} {} } 78 | } 79 | 80 | % #1: attribute 81 | % #2: item 82 | % #3: value 83 | \cs_new_protected:Npn \acro_attribute_set:nnn #1#2#3 84 | { 85 | \acro_attribute_if_exist:nTF {#1} 86 | { 87 | \cs_gset:cpx 88 | {____acro_attribute_ \tl_to_str:n {#1::#2} :} 89 | { \exp_not:n { \exp_not:n {#3} } } 90 | } 91 | { \msg_error:nnn {acro} {attribute-undefined} {#1} } 92 | } 93 | \cs_generate_variant:Nn \acro_attribute_set:nnn {nnx,nne} 94 | 95 | % #1: attribute 96 | % #2: item 97 | \cs_new_protected:Npn \acro_attribute_unset:nn #1#2 98 | { \cs_undefine:c {____acro_attribute_ \tl_to_str:n {#1::#2} :} } 99 | 100 | % #1: attribute 101 | % #2: item 102 | \cs_new:Npn \acro_attribute_get:nn #1#2 103 | { 104 | \acro_attribute_if_exist:nTF {#1} 105 | { 106 | \cs_if_exist:cTF {____acro_attribute_ \tl_to_str:n {#1::#2} :} 107 | { \use:c {____acro_attribute_ \tl_to_str:n {#1::#2} :} } 108 | { 109 | \acro_if_debug:T 110 | { \msg_expandable_error:nnn {acro} {attribute-not-set} {#1::#2} } 111 | } 112 | } 113 | { \msg_expandable_error:nnn {acro} {attribute-undefined} {#1} } 114 | } 115 | \cs_generate_variant:Nn \acro_attribute_get:nn {ne} 116 | 117 | % #1: attribute 118 | % #2: item 119 | \prg_new_conditional:Npnn \acro_attribute_if_set:nn #1#2 {p,T,F,TF} 120 | { 121 | \acro_attribute_if_exist:nTF {#1} 122 | { 123 | \cs_if_exist:cTF {____acro_attribute_ \tl_to_str:n {#1::#2} :} 124 | { \prg_return_true: } 125 | { \prg_return_false: } 126 | } 127 | { \prg_return_false: } 128 | } 129 | \prg_generate_conditional_variant:Nnn \acro_attribute_if_set:nn {ne} {p,T,F,TF} 130 | 131 | % #1: attribute 132 | % #2: item 133 | \prg_new_conditional:Npnn \__acro_if_attribute_eq:nnn #1#2#3 {p,T,F,TF} 134 | { 135 | \tl_if_eq:enTF 136 | { \use:c {____acro_attribute_ \tl_to_str:n {#1::#2} :} } 137 | {#3} 138 | { \prg_return_true: } 139 | { \prg_return_false: } 140 | } 141 | 142 | % #1: attribute 143 | % #2: item 144 | \cs_new_protected:Npn \acro_attribute_show:nn #1#2 145 | { 146 | \acro_attribute_if_exist:nTF {#1} 147 | { 148 | \iow_term:n {} 149 | \iow_term:x 150 | { 151 | \c_space_tl \c_space_tl 152 | \tl_to_str:n {#1::#2} 153 | \c_space_tl \c_space_tl == \c_space_tl \c_space_tl 154 | {\use:c {____acro_attribute_ \tl_to_str:n {#1::#2} :}} 155 | } 156 | \iow_term:n {} 157 | } 158 | { \msg_error:nnn {acro} {attribute-undefined} {#1} } 159 | } 160 | 161 | % ---------------------------------------------------------------------------- 162 | % option setup: 163 | \cs_new_protected:Npn \acro_setup:n #1 164 | { \keys_set:nn {acro} {#1} } 165 | 166 | % ---------------------------------------------------------------------------- 167 | \AcroModuleEnd 168 | -------------------------------------------------------------------------------- /code/acro.commands.code.tex: -------------------------------------------------------------------------------- 1 | \AcroModule{commands}{frameworks for user commands} 2 | 3 | % -------------------------------------------------------------------------- 4 | % case insensitivity of the ID: 5 | \bool_new:N \g__acro_case_sensitive_bool 6 | 7 | \cs_new:Npn \acro_case_insensitive:n #1 8 | { 9 | \bool_if:NTF \g__acro_case_sensitive_bool 10 | { \tl_to_str:n {#1} } 11 | { \str_lowercase:n {#1} } 12 | } 13 | 14 | \cs_new_protected:Npn \acro_protected_case_insensitive:n #1 15 | { \acro_case_insensitive:n {#1} } 16 | 17 | \cs_new:Npn \acro_case_insensitive:Nn #1#2 18 | { \exp_args:Ne #1 { \acro_case_insensitive:n {#2} } } 19 | 20 | \keys_define:nn {acro} 21 | { 22 | case-sensitive .bool_gset:N = \g__acro_case_sensitive_bool , 23 | case-insensitive .bool_gset_inverse:N = \g__acro_case_sensitive_bool , 24 | case-sensitive .initial:n = true 25 | } 26 | 27 | % ---------------------------------------------------------------------------- 28 | % typeset endings and ending forms: 29 | \bool_new:N \l__acro_include_endings_bool 30 | 31 | % #1: id 32 | % #2: property 33 | % #3: ending 34 | \cs_new:Npn \__acro_get_ending:nnn #1#2#3 35 | { 36 | \use:c {acro_if_#3:T} 37 | { \acro_property_get:nn {#1} {#2-#3} } 38 | } 39 | 40 | % #1: id 41 | % #2: property 42 | \cs_new:Npn \__acro_ending:nn #1#2 43 | { 44 | \tl_map_tokens:Nn \l__acro_endings_tl 45 | { \__acro_get_ending:nnn {#1} {#2} } 46 | } 47 | 48 | % #1: id 49 | % #2: property 50 | % #3: ending 51 | \cs_new:Npn \__acro_get_ending_form:nnn #1#2#3 52 | { 53 | \acro_property_if_set:nnT {#1} {#2-#3-form} 54 | { 55 | \use:c {acro_if_#3:T} 56 | { 57 | \acro_property_get:nn {#1} {#2-#3-form} 58 | \tl_map_break:n { \use_ii:nnn } 59 | } 60 | } 61 | } 62 | 63 | % #1: id 64 | % #2: property 65 | \cs_new:Npn \acro_ending_form:nnTF #1#2#3#4 66 | { 67 | \tl_map_tokens:Nn \l__acro_endings_tl 68 | { \__acro_get_ending_form:nnn {#1} {#2} } 69 | \use_ii:nn {#3} {#4} 70 | } 71 | 72 | % #1: id 73 | % #2: property 74 | \cs_new:Npn \acro_ending_form:nnT #1#2#3 75 | { \acro_ending_form:nnTF {#1} {#2} {#3} {} } 76 | 77 | % #1: id 78 | % #2: property 79 | \cs_new:Npn \acro_ending_form:nnF #1#2#3 80 | { \acro_ending_form:nnTF {#1} {#2} {} {#3} } 81 | 82 | % #1: id 83 | % #2: property 84 | \cs_new:Npn \acro_ending_form:nn #1#2 85 | { \acro_ending_form:nnTF {#1} {#2} {} {} } 86 | 87 | % #1: id 88 | % #2: property 89 | % #3: ending 90 | \cs_new:Npn \__acro_check_ending_form:nnn #1#2#3 91 | { 92 | \acro_property_if_set:nnT {#1} {#2-#3-form} 93 | { \use:c {acro_if_#3:T} { \tl_map_break:n { \use_ii:nnn } } } 94 | } 95 | 96 | % #1: id 97 | % #2: property 98 | \cs_new:Npn \acro_if_ending_form:nnTF #1#2#3#4 99 | { 100 | \tl_map_tokens:Nn \l__acro_endings_tl 101 | { \__acro_check_ending_form:nnn {#1} {#2} } 102 | \use_ii:nn {#3} {#4} 103 | } 104 | 105 | % #1: id 106 | % #2: property 107 | \cs_new:Npn \acro_if_ending_form:nnT #1#2#3 108 | { \acro_if_ending_form:nnTF {#1} {#2} {#3} {} } 109 | 110 | % #1: id 111 | % #2: property 112 | \cs_new:Npn \acro_if_ending_form:nnF #1#2#3 113 | { \acro_if_ending_form:nnTF {#1} {#2} {} {#3} } 114 | 115 | % -------------------------------------------------------------------------- 116 | % typeset acronyms: 117 | % #1: id 118 | % #2: property 119 | \cs_new:Npn \__acro_article:nn #1#2 120 | { 121 | \bool_if:NT \l__acro_article_bool 122 | { 123 | \tl_map_tokens:Nn \g__acro_articles_tl 124 | { \__acro_article:nnn {#1} {#2} } 125 | } 126 | } 127 | 128 | % #1: id 129 | % #2: property 130 | % #3: article 131 | \cs_new:Npn \__acro_article:nnn #1#2#3 132 | { 133 | \bool_if:cT {l__acro_article_#3_bool} 134 | { 135 | \tl_map_break:n 136 | { \acro_property_get:nn {#1} {#2-#3} \exp_stop_f: } 137 | } 138 | } 139 | 140 | % #1: id 141 | % #2: property 142 | \cs_new_protected:Npn \__acro_write:nn #1#2 143 | { 144 | \acro_property_if_exist:nTF {#2-acc} 145 | { 146 | \__acro_accsupp:ee 147 | { \__acro_write_acronym_acc:nn {#1} {#2-acc} } 148 | { \__acro_write_acronym:nn {#1} {#2} } 149 | } 150 | { \__acro_write_acronym:nn {#1} {#2} } 151 | } 152 | 153 | % #1: id 154 | % #2: property 155 | \cs_new_protected:Npn \__acro_write_acronym:nn #1#2 156 | { 157 | \bool_if:NT \l__acro_article_bool 158 | { 159 | \__acro_upper:n { \__acro_article:nn {#1} {#2} } 160 | \bool_set_false:N \l__acro_article_bool 161 | \bool_set_false:N \l__acro_upper_bool 162 | } 163 | \bool_lazy_and:nnTF 164 | { \acro_property_if_eq_p:nn {#2} {long} } 165 | { \acro_if_first_p:n {#1} } 166 | { \acro_format:nnn {#1} {first-#2} } 167 | { \acro_format:nnn {#1} {#2} } 168 | { 169 | \__acro_upper:n 170 | { 171 | \acro_if_ending_form:nnTF {#1} {#2} 172 | { \acro_ending_form:nn {#1} {#2} } 173 | { \acro_property_get:nn {#1} {#2} } 174 | } 175 | } 176 | } 177 | 178 | % #1: id 179 | % #2: property 180 | \cs_new:Npn \__acro_write_acronym_acc:nn #1#2 181 | { 182 | \__acro_upper:n 183 | { 184 | \__acro_article:nn {#1} {#2} 185 | \acro_if_ending_form:nnTF {#1} {#2} 186 | { \acro_ending_form:nn {#1} {#2} } 187 | { \acro_property_get:nn {#1} {#2} } 188 | } 189 | } 190 | 191 | % #1: id 192 | % #2: property 193 | \cs_new_protected:Npn \acro_write:nn #1#2 194 | { 195 | \acro_property_if_set:nnT {#1} {#2} 196 | { 197 | \group_begin: 198 | \acro_if_short:nT {#2} { \acro_soft_upper: } 199 | \__acro_make_link:nnn {#1} {#2} 200 | { 201 | \acro_locale:nnn {#1} {#2} 202 | { 203 | \__acro_write:nn {#1} {#2} 204 | \bool_if:NT \l__acro_include_endings_bool 205 | { 206 | \acro_if_ending_form:nnF {#1} {#2} 207 | { \__acro_ending:nn {#1} {#2} } 208 | } 209 | } 210 | } 211 | \group_end: 212 | \bool_if:NF \l__acro_include_endings_bool 213 | { 214 | \acro_if_ending_form:nnF {#1} {#2} 215 | { \__acro_ending:nn {#1} {#2} } 216 | } 217 | \acro_property_if_eq:nnT {#2} {long} 218 | { \acro_property_get:nn {#1} {long-post} } 219 | \bool_set_false:N \l__acro_upper_bool 220 | \bool_set_false:N \l__acro_article_bool 221 | } 222 | } 223 | \cs_generate_variant:Nn \acro_write:nn {e} 224 | 225 | \keys_define:nn {acro} 226 | { 227 | include-endings .bool_set:N = \l__acro_include_endings_bool , 228 | include-endings .initial:n = true 229 | } 230 | 231 | 232 | % -------------------------------------------------------------------------- 233 | % #1: boolean 234 | % #2: id 235 | \cs_new_protected:Npn \acro_finalize:nn #1#2 236 | { 237 | \bool_if:NF \g__acro_cited_bool 238 | { \acro_cite_if:nnT {#1} {#2} { \acro_cite:n {#2} } } 239 | \bool_gset_false:N \g__acro_cited_bool 240 | \acro_property_if_set:nnT {#2} {post} 241 | { \acro_property_get:nn {#2} {post} } 242 | \bool_lazy_all:nT 243 | { 244 | { \l__acro_label_bool } 245 | { \l__acro_use_bool } 246 | { !#1 } 247 | } 248 | { 249 | \acro_if_first:nT {#2} 250 | { 251 | \acro_property_if_set:nnF {#2} {label} 252 | { 253 | \acro_property_set:nnn {#2} {label} {#2} 254 | \label { \l_acro_label_prefix_tl #2 } 255 | } 256 | } 257 | } 258 | \bool_lazy_and:nnT 259 | { \l__acro_use_bool } 260 | { !#1 } 261 | { 262 | \acro_use:n {#2} 263 | \acro_record_page:n {#2} 264 | \acro_index:n {#2} 265 | } 266 | } 267 | \cs_generate_variant:Nn \acro_finalize:nn {ne} 268 | 269 | % -------------------------------------------------------------------------- 270 | % define acronym typesetting commands: 271 | \bool_new:N \l__acro_star_bool 272 | \tl_new:N \l__acro_options_tl 273 | 274 | \cs_new:Npn \__acro_remove_bs:N #1 275 | { \exp_after:wN \use_none:n \token_to_str:N #1 } 276 | 277 | \tl_new:N \l__acro_begin_command_hook_tl 278 | \tl_new:N \l__acro_end_command_hook_tl 279 | \tl_new:N \l_acro_id_tl 280 | \tl_new:N \AcronymID 281 | 282 | \int_new:N \l_acro_nest_level_int 283 | 284 | % #1: csname 285 | % #2: xparse csname 286 | % #3: action 287 | \cs_set_protected:Npn \acro_new_definition_command:NNn #1#2#3 288 | { 289 | % internal command for \NewAcroCommand 290 | % ##1: csname 291 | % ##2: arg spec 292 | % ##3: code with arg numbers n=n+2 293 | \cs_new_protected:cpn {acro_command_#3:Nnn} ##1##2##3 294 | { 295 | \exp_args:Nc \DeclareDocumentCommand 296 | { base \__acro_remove_bs:N ##1 } {##2} 297 | { 298 | \acro_begin: 299 | \int_incr:N \l_acro_nest_level_int 300 | \l__acro_begin_command_hook_tl 301 | \cs_set:Npn \nospace { \exp:w \exp_end_continue_f:w } 302 | \acro_check_definition:nT 303 | {####1} 304 | { 305 | \keys_set:nV {acro} \l__acro_options_tl 306 | \tl_set:Ne \l_acro_id_tl { \acro_case_insensitive:n {####1} } 307 | \tl_set_eq:NN \AcronymID \l_acro_id_tl 308 | ##3 309 | \acro_finalize:ne 310 | { \l__acro_star_bool } 311 | { \acro_case_insensitive:n {####1} } 312 | \l__acro_end_command_hook_tl 313 | \int_decr:N \l_acro_nest_level_int 314 | } 315 | \acro_end: 316 | } 317 | \use:x 318 | { 319 | \exp_not:n { #2 ##1 {so} } 320 | { 321 | \exp_not:n 322 | { 323 | \mode_leave_vertical: 324 | \bool_set_false:N \l__acro_star_bool 325 | \tl_clear:N \l__acro_options_tl 326 | \IfBooleanT {####1} { \bool_set_true:N \l__acro_star_bool } 327 | \IfNoValueF {####2} { \tl_set:Nn \l__acro_options_tl {####2} } 328 | } 329 | \exp_not:c { base \__acro_remove_bs:N ##1 } 330 | } 331 | } 332 | } 333 | % define \NewAcroCommand 334 | \NewDocumentCommand #1 {mm+m} 335 | { \use:c {acro_command_#3:Nnn} ##1 {##2} {##3} } 336 | } 337 | 338 | \acro_new_definition_command:NNn 339 | \NewAcroCommand 340 | \NewDocumentCommand 341 | {new} 342 | 343 | \acro_new_definition_command:NNn 344 | \RenewAcroCommand 345 | \RenewDocumentCommand 346 | {renew} 347 | 348 | \acro_new_definition_command:NNn 349 | \DeclareAcroCommand 350 | \DeclareDocumentCommand 351 | {declare} 352 | 353 | \acro_new_definition_command:NNn 354 | \ProvideAcroCommand 355 | \ProvideDocumentCommand 356 | {provide} 357 | 358 | \keys_define:nn {acro/commands} 359 | { 360 | begin .code:n = 361 | \tl_put_right:Nn \l__acro_begin_command_hook_tl {#1} , 362 | end .code:n = 363 | \tl_put_right:Nn \l__acro_end_command_hook_tl {#1} , 364 | clear .choice: , 365 | clear / begin .code:n = 366 | \tl_clear:N \l__acro_begin_command_hook_tl , 367 | clear / end .code:n = 368 | \tl_clear:N \l__acro_end_command_hook_tl , 369 | clear / all .code:n = 370 | \tl_clear:N \l__acro_begin_command_hook_tl 371 | \tl_clear:N \l__acro_end_command_hook_tl 372 | } 373 | 374 | % -------------------------------------------------------------------------- 375 | \AcroModuleEnd 376 | -------------------------------------------------------------------------------- /code/acro.definitions.code.tex: -------------------------------------------------------------------------------- 1 | \AcroModule{definitions}{definitions of user commands} 2 | 3 | % -------------------------------------------------------------------------- 4 | % commands for typesetting acronyms: 5 | \NewAcroCommand \ac {m} 6 | { \UseAcroTemplate {first} {#1} } 7 | \NewAcroCommand \acp {m} 8 | { \acroplural \UseAcroTemplate {first} {#1} } 9 | \NewAcroCommand \iac {m} 10 | { \acroindefinite \UseAcroTemplate {first} {#1} } 11 | \NewAcroCommand \Ac {m} 12 | { \acroupper \UseAcroTemplate {first} {#1} } 13 | \NewAcroCommand \Acp {m} 14 | { \acroplural \acroupper \UseAcroTemplate {first} {#1} } 15 | \NewAcroCommand \Iac {m} 16 | { \acroupper \acroindefinite \UseAcroTemplate {first} {#1} } 17 | 18 | \NewAcroCommand \acs {m} 19 | { \UseAcroTemplate {short} {#1} } 20 | \NewAcroCommand \acsp {m} 21 | { \acroplural \UseAcroTemplate {short} {#1} } 22 | \NewAcroCommand \iacs {m} 23 | { \acroindefinite \UseAcroTemplate {short} {#1} } 24 | \NewAcroCommand \Acs {m} 25 | { \acroupper \UseAcroTemplate {short} {#1} } 26 | \NewAcroCommand \Acsp {m} 27 | { \acroplural \acroupper \UseAcroTemplate {short} {#1} } 28 | \NewAcroCommand \Iacs {m} 29 | { \acroupper \acroindefinite \UseAcroTemplate {short} {#1} } 30 | 31 | \NewAcroCommand \acl {m} 32 | { \UseAcroTemplate {long} {#1} } 33 | \NewAcroCommand \aclp {m} 34 | { \acroplural \UseAcroTemplate {long} {#1} } 35 | \NewAcroCommand \iacl {m} 36 | { \acroindefinite \UseAcroTemplate {long} {#1} } 37 | \NewAcroCommand \Acl {m} 38 | { \acroupper \UseAcroTemplate {long} {#1} } 39 | \NewAcroCommand \Aclp {m} 40 | { \acroplural \acroupper \UseAcroTemplate {long} {#1} } 41 | \NewAcroCommand \Iacl {m} 42 | { \acroupper \acroindefinite \UseAcroTemplate {long} {#1} } 43 | 44 | \NewAcroCommand \aca {m} 45 | { \UseAcroTemplate {alt} {#1} } 46 | \NewAcroCommand \acap {m} 47 | { \acroplural \UseAcroTemplate {alt} {#1} } 48 | \NewAcroCommand \iaca {m} 49 | { \acroindefinite \UseAcroTemplate {alt} {#1} } 50 | \NewAcroCommand \Aca {m} 51 | { \acroupper \UseAcroTemplate {alt} {#1} } 52 | \NewAcroCommand \Acap {m} 53 | { \acroplural \acroupper \UseAcroTemplate {alt} {#1} } 54 | \NewAcroCommand \Iaca {m} 55 | { \acroupper \acroindefinite \UseAcroTemplate {alt} {#1} } 56 | 57 | \NewAcroCommand \acf {m} 58 | { \acrofull \UseAcroTemplate {first} {#1} } 59 | \NewAcroCommand \acfp {m} 60 | { \acrofull \acroplural \UseAcroTemplate {first} {#1} } 61 | \NewAcroCommand \iacf {m} 62 | { \acrofull \acroindefinite \UseAcroTemplate {first} {#1} } 63 | \NewAcroCommand \Acf {m} 64 | { \acrofull \acroupper \UseAcroTemplate {first} {#1} } 65 | \NewAcroCommand \Acfp {m} 66 | { \acrofull \acroplural \acroupper \UseAcroTemplate {first} {#1} } 67 | \NewAcroCommand \Iacf {m} 68 | { \acrofull \acroupper \acroindefinite \UseAcroTemplate {first} {#1} } 69 | 70 | \NewAcroCommand \acshow {m} 71 | { \acrodonotuse \UseAcroTemplate {show} {#1} } 72 | 73 | % -------------------------------------------------------------------------- 74 | \DeclareAcroEnding {plural} {s} {s} 75 | 76 | \DeclareAcroArticle {indefinite} {a} 77 | 78 | \ProvideExpandableDocumentCommand \nospace {} {} 79 | 80 | % -------------------------------------------------------------------------- 81 | % acronym templates: 82 | \NewAcroTemplate {long-short} 83 | { 84 | \acroiffirstTF 85 | { 86 | \acrowrite {long} 87 | \acspace 88 | ( 89 | \acroifT {foreign} { \acrowrite {foreign} ,~ } 90 | \acrowrite {short} 91 | \acroifT {alt} { ~ \acrotranslate {or} ~ \acrowrite {alt} } 92 | \acrogroupcite 93 | ) 94 | } 95 | { \acrowrite {short} } 96 | } 97 | 98 | \NewAcroTemplate {short-long} 99 | { 100 | \acrowrite {short} 101 | \acroiffirstT 102 | { 103 | \space 104 | ( 105 | \acroifT {alt} { \acrotranslate {or} ~ \acrowrite {alt} ,~ } 106 | \acroifT {foreign} { \acrowrite {foreign} ,~ } 107 | \acrowrite {long} 108 | \acrogroupcite 109 | ) 110 | } 111 | } 112 | 113 | \NewAcroTemplate {footnote} 114 | { 115 | \acrowrite {short} 116 | \acroiffirstT 117 | { 118 | \acfootnote 119 | { 120 | \acroifT {alt} { \acrotranslate {or} ~ \acrowrite {alt} ,~ } 121 | \acroifT {foreign} { \acrowrite {foreign} ,~ } 122 | \acrowrite {long} 123 | \acrogroupcite 124 | \acroendfootnote 125 | } 126 | } 127 | } 128 | 129 | \ProvideDocumentCommand \acroendfootnote {} {} 130 | 131 | \NewAcroTemplate {long} 132 | { \acrowrite {long} } 133 | 134 | \NewAcroTemplate {single} 135 | { \acrowrite {single} } 136 | 137 | \NewAcroTemplate {short} 138 | { \acrowrite {short} } 139 | 140 | \NewAcroTemplate {alt} 141 | { 142 | \acroifTF {alt} 143 | { \acrowrite {alt} } 144 | { \acrowrite {short} } 145 | } 146 | 147 | \NewAcroTemplate {show} 148 | { 149 | \iow_term:n {} 150 | \iow_term:x 151 | { 152 | The~ acronym~ `\AcronymID'~ has~ the~ properties~ (without~ outer~ 153 | braces): 154 | } 155 | \iow_term:n {} 156 | \AcroPropertiesMap { \acroshow {##1} } 157 | \iow_term:n {} 158 | } 159 | 160 | % -------------------------------------------------------------------------- 161 | % heading templates: 162 | \NewAcroTemplate[heading] {none} { } 163 | 164 | \NewAcroTemplate[heading] {section} 165 | { \section { \acrolistname } } 166 | 167 | \NewAcroTemplate[heading] {section*} 168 | { \section* { \acrolistname } } 169 | 170 | \acro_if_komascript:T 171 | { 172 | \NewAcroTemplate[heading] {addsec} 173 | { \addsec { \acrolistname } } 174 | \NewAcroTemplate[heading] {addsec*} 175 | { \addsec* { \acrolistname } } 176 | } 177 | 178 | \cs_if_exist:NT \chapter 179 | { 180 | \NewAcroTemplate[heading] {chapter} 181 | { \chapter { \acrolistname } } 182 | \NewAcroTemplate[heading] {chapter*} 183 | { \chapter* { \acrolistname } } 184 | \acro_if_komascript:T 185 | { 186 | \NewAcroTemplate[heading] {addchap} 187 | { \addchap { \acrolistname } } 188 | \NewAcroTemplate[heading] {addchap*} 189 | { \addchap* { \acrolistname } } 190 | } 191 | } 192 | 193 | % -------------------------------------------------------------------------- 194 | % list templates: 195 | \NewAcroTemplate[list] {description} 196 | { 197 | \acroheading 198 | \acropreamble 199 | \begin {description} 200 | \acronymsmapF 201 | { 202 | \item [ \acrowrite {short} \acroifT {alt} {/} \acrowrite {alt} ] 203 | \acrowrite {list} 204 | \acroifanyT {foreign,extra} {~(} 205 | \acrowrite {foreign} 206 | \acroifallT {foreign,extra} {,~} 207 | \acrowrite {extra} 208 | \acroifanyT {foreign,extra} {)} 209 | \acropagefill 210 | \acropages 211 | { \acrotranslate {page} \nobreakspace } 212 | { \acrotranslate {pages} \nobreakspace } 213 | } 214 | { \item \AcroRerun } 215 | \end {description} 216 | } 217 | 218 | \tl_new:N \l_acro_table_colspec_tl 219 | \keys_define:nn {acro/templates} 220 | { 221 | colspec .tl_set:N = \l_acro_table_colspec_tl , 222 | colspec .initial:n = {>{\bfseries}lp{.7\linewidth}} 223 | } 224 | 225 | \NewAcroTemplate[list] {tabular} 226 | { 227 | \AcroNeedPackage {array} 228 | \acronymsmapF 229 | { 230 | \AcroAddRow 231 | { 232 | \acrowrite {short} 233 | \acroifT {alt} {/} \acrowrite {alt} 234 | & 235 | \acrowrite {list} 236 | \acroifanyT {foreign,extra} {~(} 237 | \acrowrite {foreign} 238 | \acroifallT {foreign,extra} {,~} 239 | \acrowrite {extra} 240 | \acroifanyT {foreign,extra} {)} 241 | \acropagefill 242 | \acropages 243 | { \acrotranslate {page} \nobreakspace } 244 | { \acrotranslate {pages} \nobreakspace } 245 | \tabularnewline 246 | } 247 | } 248 | { \AcroRerun } 249 | \acroheading 250 | \acropreamble 251 | \par \noindent 252 | \exp_args:NnV 253 | \begin {tabular} \l_acro_table_colspec_tl 254 | \AcronymTable 255 | \end {tabular} 256 | } 257 | 258 | \NewAcroTemplate[list] {longtable} 259 | { 260 | \AcroNeedPackage {array,longtable} 261 | \acronymsmapF 262 | { 263 | \AcroAddRow 264 | { 265 | \acrowrite {short} 266 | \acroifT {alt} {/} \acrowrite {alt} 267 | & 268 | \acrowrite {list} 269 | \acroifanyT {foreign,extra} {~(} 270 | \acrowrite {foreign} 271 | \acroifallT {foreign,extra} {,~} 272 | \acrowrite {extra} 273 | \acroifanyT {foreign,extra} {)} 274 | \acropagefill 275 | \acropages 276 | { \acrotranslate {page} \nobreakspace } 277 | { \acrotranslate {pages} \nobreakspace } 278 | \tabularnewline 279 | } 280 | } 281 | { \AcroRerun } 282 | \acroheading 283 | \acropreamble 284 | \par \noindent 285 | \exp_args:NnV 286 | \begin {longtable} \l_acro_table_colspec_tl 287 | \AcronymTable 288 | \end {longtable} 289 | \addtocounter {table} {-1} 290 | } 291 | 292 | \NewAcroTemplate[list] {supertabular} 293 | { 294 | \AcroNeedPackage {array,supertabular} 295 | \acronymsmapF 296 | { 297 | \AcroAddRow 298 | { 299 | \acrowrite {short} 300 | \acroifT {alt} {/} \acrowrite {alt} 301 | & 302 | \acrowrite {list} 303 | \acroifanyT {foreign,extra} {~(} 304 | \acrowrite {foreign} 305 | \acroifallT {foreign,extra} {,~} 306 | \acrowrite {extra} 307 | \acroifanyT {foreign,extra} {)} 308 | \acropagefill 309 | \acropages 310 | { \acrotranslate {page} \nobreakspace } 311 | { \acrotranslate {pages} \nobreakspace } 312 | \tabularnewline 313 | } 314 | } 315 | { \AcroRerun } 316 | \acroheading 317 | \acropreamble 318 | \par \noindent 319 | \exp_args:NnV 320 | \begin {supertabular} \l_acro_table_colspec_tl 321 | \AcronymTable 322 | \end {supertabular} 323 | } 324 | 325 | \NewAcroTemplate[list] {xltabular} 326 | { 327 | \AcroNeedPackage {xltabular} 328 | \acronymsmapF 329 | { 330 | \AcroAddRow 331 | { 332 | \acrowrite {short} 333 | \acroifT {alt} {/} \acrowrite {alt} 334 | & 335 | \acrowrite {list} 336 | \acroifanyT {foreign,extra} {~(} 337 | \acrowrite {foreign} 338 | \acroifallT {foreign,extra} {,~} 339 | \acrowrite {extra} 340 | \acroifanyT {foreign,extra} {)} 341 | \acropagefill 342 | \acropages 343 | { \acrotranslate {page} \nobreakspace } 344 | { \acrotranslate {pages} \nobreakspace } 345 | \tabularnewline 346 | } 347 | } 348 | { \AcroRerun } 349 | \acroheading 350 | \acropreamble 351 | \par \noindent 352 | \begin {xltabular} {\linewidth} {>{\bfseries}lX} 353 | \AcronymTable 354 | \end {xltabular} 355 | } 356 | 357 | \hook_gput_code:nnn {package/tabularray/after} {acro} 358 | { 359 | \NewTblrTheme {acro} { \DefTblrTemplate {foot} {default} {} } 360 | \NewTblrEnviron {actblr} 361 | \SetTblrOuter [actblr] { 362 | long , 363 | expand = \AcronymTable , 364 | theme = acro , 365 | entry = none , 366 | label = none 367 | } 368 | \SetTblrInner [actblr] { rowsep = 0pt } 369 | } 370 | 371 | \NewAcroTemplate [list] {tabularray} 372 | { 373 | \AcroNeedPackage {tabularray} 374 | \acronymsmapF 375 | { 376 | \AcroAddRow 377 | { 378 | \acrowrite {short} 379 | \acroifT {alt} {/} \acrowrite {alt} 380 | & 381 | \acrowrite {list} 382 | \acroifanyT {foreign,extra} {~(} 383 | \acrowrite {foreign} 384 | \acroifallT {foreign,extra} {,~} 385 | \acrowrite {extra} 386 | \acroifanyT {foreign,extra} {)} 387 | \acropagefill 388 | \acropages 389 | { \acrotranslate {page} \nobreakspace } 390 | { \acrotranslate {pages} \nobreakspace } 391 | \strut \\ 392 | } 393 | } 394 | { \AcroRerun } 395 | \acroheading 396 | \acropreamble 397 | \par \noindent 398 | \begin {actblr} { colspec = {lX[l]}, column{1} = { font = \bfseries } } 399 | \AcronymTable 400 | \end {actblr} 401 | } 402 | 403 | \let\l@acro\l@figure 404 | 405 | \NewAcroTemplate [list] {lof} 406 | { 407 | \acroheading 408 | \acropreamble 409 | \acronopagerange 410 | \acroneedpages 411 | \acronymsmapF 412 | { 413 | \contentsline {acro} 414 | { 415 | \numberline 416 | { \acrowrite {short} \acroifT {alt} {/} \acrowrite {alt} } 417 | { 418 | \acrowrite {list} 419 | \acroifanyT {foreign,extra} {~(} 420 | \acrowrite {foreign} 421 | \acroifallT {foreign,extra} {,~} 422 | \acrowrite {extra} 423 | \acroifanyT {foreign,extra} {)} 424 | } 425 | } 426 | { \acropages {} {} } 427 | {} 428 | } 429 | { \AcroRerun } 430 | } 431 | 432 | \NewAcroTemplate [list] {toc} 433 | { 434 | \acroheading 435 | \acropreamble 436 | \acronopagerange 437 | \acroneedpages 438 | \acronymsmapF 439 | { 440 | \contentsline { \acroifchapterTF {chapter} {section} } 441 | { \acrowrite {short} \acroifT {alt} {/} \acrowrite {alt} } 442 | {}{} 443 | \contentsline { \acroifchapterF {sub} section } 444 | { 445 | \acrowrite {list} 446 | \acroifanyT {foreign,extra} {~(} 447 | \acrowrite {foreign} 448 | \acroifallT {foreign,extra} {,~} 449 | \acrowrite {extra} 450 | \acroifanyT {foreign,extra} {)} 451 | } 452 | { \acropages {} {} } 453 | {} 454 | } 455 | { \AcroRerun } 456 | } 457 | 458 | % -------------------------------------------------------------------------- 459 | % translations: 460 | % list name 461 | \DeclareAcroTranslation {list-name} 462 | { 463 | Fallback = Acronyms , 464 | English = Acronyms , 465 | French = Acronymes , 466 | German = Abk\"urzungen , 467 | Italian = Acronimi , 468 | Portuguese = Acr\'onimos , 469 | Spanish = Siglas , 470 | Catalan = Sigles 471 | } 472 | 473 | % page name 474 | \DeclareAcroTranslation {page} 475 | { 476 | Fallback = p\abbrdot , 477 | English = p\abbrdot , 478 | French = p\abbrdot , 479 | German = S\abbrdot , 480 | Italian = p\abbrdot , 481 | Portuguese = p\abbrdot , 482 | Spanish = p\'ag\abbrdot , 483 | Catalan = p\`ag\abbrdot 484 | } 485 | 486 | % pages name 487 | \DeclareAcroTranslation {pages} 488 | { 489 | Fallback = pp\abbrdot , 490 | English = pp\abbrdot , 491 | French = p\abbrdot , 492 | German = S\abbrdot , 493 | Italian = pp\abbrdot , 494 | Portuguese = pp\abbrdot , 495 | Spanish = p\'ags\abbrdot , 496 | Catalan = p\`ag\abbrdot 497 | } 498 | 499 | % following page 500 | \DeclareAcroTranslation {sequens} 501 | { 502 | Fallback = f\abbrdot , 503 | English = f\abbrdot , 504 | French = sq\abbrdot , 505 | German = f\abbrdot , 506 | Italian = s\abbrdot , 507 | Portuguese = s\abbrdot , 508 | Spanish = s\abbrdot , 509 | Catalan = seq\abbrdot 510 | } 511 | 512 | % following pages 513 | \DeclareAcroTranslation {sequentes} 514 | { 515 | Fallback = ff\abbrdot , 516 | English = ff\abbrdot , 517 | French = sqq\abbrdot , 518 | German = ff\abbrdot , 519 | Italian = ss\abbrdot , 520 | Portuguese = ss\abbrdot , 521 | Spanish = ss\abbrdot , 522 | Catalan = et seq\abbrdot 523 | } 524 | 525 | % also 526 | \DeclareAcroTranslation {also} 527 | { 528 | Fallback = also , 529 | English = also , 530 | French = aussi , 531 | German = auch , 532 | Italian = anche , 533 | Portuguese = tamb\'{e}m , 534 | Spanish = tambien , 535 | Catalan = tamb\'{e} 536 | } 537 | 538 | % or 539 | \DeclareAcroTranslation {or} 540 | { 541 | Fallback = or , 542 | English = or , 543 | French = ou , 544 | German = oder , 545 | Italian = o , 546 | Portuguese = ou , 547 | Spanish = o , 548 | Catalan = o 549 | } 550 | 551 | % and 552 | \DeclareAcroTranslation {and} 553 | { 554 | Fallback = and , 555 | English = and , 556 | French = et , 557 | German = und , 558 | Italian = e , 559 | Portuguese = e , 560 | Spanish = y , 561 | Catalan = i 562 | } 563 | 564 | % -------------------------------------------------------------------------- 565 | \AcroModuleEnd 566 | -------------------------------------------------------------------------------- /code/acro.formatting.code.tex: -------------------------------------------------------------------------------- 1 | \AcroModule{formatting}{formatting of acronyms} 2 | 3 | \bool_new:N \l__acro_format_replace_bool 4 | 5 | % sets the format from the global option: 6 | % #1: property 7 | \cs_new:Npn \__acro_global_format:n #1 8 | { 9 | \acro_property_if_alias:nTF {#1} 10 | { 11 | \tl_if_empty:cTF {l__acro_format_ #1 _tl} 12 | { \__acro_use_global_format:n { \acro_property_alias:n {#1} } } 13 | { \__acro_use_global_format:n {#1} } 14 | } 15 | { \__acro_use_global_format:n {#1} } 16 | } 17 | 18 | % #1: property 19 | \cs_new:Npn \__acro_use_global_format:n #1 20 | { 21 | \tl_if_exist:cTF {l__acro_format_ #1 _tl} 22 | { 23 | \tl_if_empty:cTF {l__acro_format_ #1 _tl} 24 | { \use:n } 25 | { \exp_not:v {l__acro_format_ #1 _tl} } 26 | } 27 | { \use:n } 28 | } 29 | 30 | % #1: id 31 | % #2: property 32 | % #3: insert if false 33 | \cs_new:Npn \__acro_property_format:nnF #1#2#3 34 | { 35 | \acro_property_if_set:nnTF {#1} {#2-format} 36 | { \acro_property_get:nn {#1} {#2-format} } 37 | { 38 | \acro_if_format_alias:nnTF {#1} {#2} 39 | { 40 | \acro_property_get:nn {#1} 41 | { \acro_property_alias:n {#2} -format } 42 | } 43 | {#3} 44 | } 45 | } 46 | 47 | % #1: id 48 | % #1: property 49 | \prg_new_conditional:Npnn \acro_if_format_alias:nn #1#2 {TF} 50 | { 51 | \acro_property_if_alias:nTF {#2} 52 | { 53 | \acro_property_if_set:nnTF {#1} 54 | { \acro_property_alias:n {#2} -format } 55 | { \prg_return_true: } 56 | { \prg_return_false: } 57 | } 58 | { \prg_return_false: } 59 | } 60 | 61 | % #1: id 62 | % #1: property 63 | \cs_new:Npn \__acro_property_format:nn #1#2 64 | { \__acro_property_format:nnF {#1} {#2} { \use:n } } 65 | 66 | % sets the individual format: 67 | % #1: id 68 | % #2: property 69 | % #3: text 70 | \cs_new:Npn \acro_format:nnn #1#2#3 71 | { 72 | { 73 | \bool_if:NTF \l__acro_format_replace_bool 74 | { 75 | \__acro_property_format:nnF {#1} {#2} 76 | { \__acro_global_format:n {#2} } 77 | { \__acro_pdf_comment:nnn {#1} {#2} {#3} } 78 | } 79 | { 80 | \__acro_global_format:n {#2} 81 | { 82 | \__acro_property_format:nn {#1} {#2} 83 | { \__acro_pdf_comment:nnn {#1} {#2} {#3} } 84 | } 85 | } 86 | } 87 | } 88 | \cs_generate_variant:Nn \acro_format:nnn {e} 89 | 90 | \cs_new:Npn \acro_index_format:nnn #1#2#3 91 | { 92 | { 93 | \bool_if:NTF \l__acro_format_replace_bool 94 | { 95 | \__acro_property_format:nnF {#1} {#2} 96 | { \__acro_global_format:n {#2} } 97 | {#3} 98 | } 99 | { 100 | \__acro_global_format:n {#2} 101 | { \__acro_property_format:nn {#1} {#2} {#3} } 102 | } 103 | } 104 | } 105 | 106 | % #1: property: 107 | \cs_new_protected:Npn \acro_new_format:n #1 108 | { 109 | \tl_new:c {l__acro_format_#1_tl} 110 | \keys_define:nn {acro/format} { #1 .tl_set:c = l__acro_format_#1_tl } 111 | } 112 | 113 | \acro_new_format:n {short} 114 | \acro_new_format:n {long} 115 | \acro_new_format:n {alt} 116 | \acro_new_format:n {extra} 117 | \acro_new_format:n {foreign} 118 | \acro_new_format:n {list} 119 | \acro_new_format:n {first-long} 120 | 121 | \keys_define:nn {acro} 122 | { 123 | format .meta:n = { format/short = #1 , format/long = #1 } , 124 | format / replace .bool_set:N = \l__acro_format_replace_bool , 125 | format / replace .initial:n = true 126 | } 127 | 128 | % ---------------------------------------------------------------------------- 129 | \AcroModuleEnd 130 | -------------------------------------------------------------------------------- /code/acro.interface.code.tex: -------------------------------------------------------------------------------- 1 | \AcroModule{interface}{definitions of user commands} 2 | 3 | % -------------------------------------------------------------------------- 4 | % helper commands 5 | \NewDocumentCommand \AcroAddRow {+m} 6 | { 7 | \tl_put_right:Ne \AcronymTable 8 | { 9 | \exp_not:n { \tl_gset:Nn \AcronymID } { \AcronymID } 10 | \exp_not:n {#1} 11 | } 12 | } 13 | 14 | \NewDocumentCommand \AcroRerun {} 15 | { \acro_rerun:n {list} } 16 | 17 | \NewDocumentCommand \AcroPropertiesMap {+m} 18 | { \acro_properties_map:n {#1} } 19 | 20 | \NewDocumentCommand \AcroAcronymsMap {+m} 21 | { \acro_map_acronyms:n { \tl_set:Nn \AcronymID {##1} #1 } } 22 | 23 | \NewExpandableDocumentCommand \AcroMapBreak {} { \acro_map_break: } 24 | 25 | \NewDocumentCommand \AcroPropertiesSet {m+m} 26 | { \acro_properties_set:nn {#1} {#2} } 27 | 28 | \NewDocumentCommand \AcroMap {m+m} 29 | { \acro_list_map:nn {#1} {#2} } 30 | 31 | \NewDocumentCommand \AcroNeedPackage {m} 32 | { 33 | \clist_map_inline:nn {#1} 34 | { 35 | \acro_package_if_loaded:nF {##1} 36 | { \msg_error:nnen {acro} {package-needed} { \AcroTemplateName } {##1} } 37 | } 38 | } 39 | 40 | % -------------------------------------------------------------------------- 41 | % general commands: 42 | \NewDocumentCommand \acsetup {+m} 43 | { \acro_setup:n {#1} } 44 | 45 | \NewDocumentCommand \acroloadstyle {m} 46 | { \acro_style_load:n {#1} } 47 | 48 | \NewExpandableDocumentCommand \acroifstarredTF {} 49 | { \bool_if:NTF \l__acro_star_bool } 50 | 51 | \NewExpandableDocumentCommand \acroifstarredT {} 52 | { \bool_if:NT \l__acro_star_bool } 53 | 54 | \NewExpandableDocumentCommand \acroifstarredF {} 55 | { \bool_if:NF \l__acro_star_bool } 56 | 57 | \NewExpandableDocumentCommand \acroifusedTF {m} 58 | { \acro_boolean_property_if:nnTF {#1} {used} } 59 | 60 | \NewExpandableDocumentCommand \acroifusedT {m} 61 | { \acro_boolean_property_if:nnT {#1} {used} } 62 | 63 | \NewExpandableDocumentCommand \acroifusedF {m} 64 | { \acro_boolean_property_if:nnF {#1} {used} } 65 | 66 | \NewDocumentCommand \acuse {m} 67 | { \acro_use:n {#1} } 68 | 69 | \NewDocumentCommand \acuseall {} 70 | { \acro_use_all: } 71 | 72 | \NewDocumentCommand \acreset {m} 73 | { \acro_reset:n {#1} } 74 | 75 | \NewDocumentCommand \acresetall {} 76 | { \acro_reset_all: } 77 | 78 | \NewExpandableDocumentCommand \acsimple {mm} 79 | { \acro_pdfstring_template:nn {#1} {#2} } 80 | 81 | \NewDocumentCommand \acbarrier {} 82 | { \acro_barrier: } 83 | 84 | \NewDocumentCommand \acswitchoff {} 85 | { \acro_switch_off: } 86 | 87 | \NewDocumentCommand \acswitchon {} 88 | { \acro_switch_on: } 89 | 90 | % -------------------------------------------------------------------------- 91 | \NewDocumentCommand \DeclareAcroProperty {st?t!t|t>m} 92 | { 93 | \acro_property_declare:en 94 | { 95 | \IfBooleanT {#1} {unique=true,} 96 | \IfBooleanT {#2} {boolean=true,} 97 | \IfBooleanT {#3} {mandatory=true,} 98 | \IfBooleanT {#4} {static=true,} 99 | \IfBooleanT {#5} {display=true} 100 | } 101 | {#6} 102 | } 103 | 104 | \NewDocumentCommand \DeclareAcroPropertyAlias {st?t!t|t>mm} 105 | { 106 | \acro_property_declare:en 107 | { 108 | \IfBooleanT {#1} {unique=true,} 109 | \IfBooleanT {#2} {boolean=true,} 110 | \IfBooleanT {#3} {mandatory=true,} 111 | \IfBooleanT {#4} {static=true,} 112 | \IfBooleanT {#5} {display=true} 113 | } 114 | {#6} 115 | \acro_property_make_alias:nn {#6} {#7} 116 | } 117 | 118 | \NewDocumentCommand \MakeAcroPropertyAlias{mm} 119 | { \acro_property_make_alias:nn {#1} {#2} } 120 | 121 | \NewDocumentCommand \NewAcroPreset {m+m} 122 | { \acro_preset_new:nn {#1} {#2} } 123 | 124 | \NewDocumentCommand \RenewAcroPreset {m+m} 125 | { \acro_preset_renew:nn {#1} {#2} } 126 | 127 | \NewDocumentCommand \DeclareAcroPreset {m+m} 128 | { \acro_preset_declare:nn {#1} {#2} } 129 | 130 | % -------------------------------------------------------------------------- 131 | \NewDocumentCommand \UseAcroTemplate {O{acronym}mO{1}} 132 | { \acro_template_use:nnn {#3} {#1} {#2} } 133 | 134 | \NewDocumentCommand \NewAcroTemplate {O{acronym}m+m} 135 | { \use:c {acro_#1_template_new:nn} {#2} {#3} } 136 | 137 | \NewDocumentCommand \RenewAcroTemplate {O{acronym}m+m} 138 | { \use:c {acro_#1_template_renew:nn} {#2} {#3} } 139 | 140 | \NewDocumentCommand \SetupAcroTemplate {O{acronym}m+m} 141 | { \acro_template_setup:nnn {#1} {#2} {#3} } 142 | 143 | \NewDocumentCommand \SetupNextAcroTemplate {O{acronym}m+m} 144 | { \acro_next_template_setup:nnn {#1} {#2} {#3} } 145 | 146 | \NewDocumentCommand \DeclareAcronym {m+m} 147 | { \acro_declare_acronym:nn {#1} {#2} } 148 | 149 | % declaring acronyms in the document body does not work, 150 | % cf. https://tex.stackexchange.com/q/568856/ 151 | % so lets prevent people from doing so: 152 | \@onlypreamble \DeclareAcronym 153 | 154 | \NewDocumentCommand \DeclareAcroEnding {mmm} 155 | { \acro_declare_ending:nnn {#1} {#2} {#3} } 156 | 157 | \NewDocumentCommand \DeclareAcroArticle {mm} 158 | { \acro_article_declare:nn {#1} {#2} } 159 | 160 | \NewDocumentCommand \DeclareAcroTranslation {m+m} 161 | { \acro_declare_translations:nn {#1} {#2} } 162 | 163 | \NewDocumentCommand \AddAcroTranslations {m+m} 164 | { \acro_add_translations:nn {#1} {#2} } 165 | 166 | \NewExpandableDocumentCommand \acrotranslate {m} 167 | { \acro_translate:n {#1} } 168 | 169 | \NewExpandableDocumentCommand \aciftrailing {} 170 | { \acro_trailing_if_tokens:nTF } 171 | 172 | \NewDocumentCommand \acfootnote {m} 173 | { \acro_footnote:n {#1} } 174 | 175 | \NewDocumentCommand \acgobbletrail {} 176 | { \bool_gset_true:N \g__acro_gobble_trail_bool } 177 | 178 | \NewExpandableDocumentCommand \acdot {} { \acro_dot: } 179 | \NewExpandableDocumentCommand \acspace {} { \acro_space: } 180 | \NewExpandableDocumentCommand \abbrdot {} { .\@ } 181 | 182 | \NewDocumentCommand \acroupper {} { \acro_upper: } 183 | \NewDocumentCommand \acrofull {} { \acro_first: } 184 | 185 | \NewDocumentCommand \printacronyms {o} 186 | { 187 | \group_begin: 188 | \IfNoValueF {#1} 189 | { \keys_set:nn {acro/list} {#1} } 190 | \acro_list: 191 | \group_end: 192 | } 193 | 194 | % -------------------------------------------------------------------------- 195 | % commands for list templates 196 | \NewDocumentCommand \acroheading {} { \acro_heading: } 197 | \NewDocumentCommand \acropreamble {} { \acro_preamble: } 198 | \NewDocumentCommand \acropostamble {} { \acro_postamble: } 199 | 200 | \NewExpandableDocumentCommand \acrolistname {} 201 | { \tl_use:N \l__acro_list_name_tl } 202 | 203 | % -------------------------------------------------------------------------- 204 | % cmmands for use in templates: 205 | \NewDocumentCommand \acronymsmapTF {+m+m+m} 206 | { 207 | \acro_acronyms_map:nTF 208 | { 209 | \tl_set:Nn \AcronymID {##1} 210 | #1 211 | } 212 | {#2} 213 | {#3} 214 | } 215 | 216 | \NewDocumentCommand \acronymsmapT {+m+m} 217 | { \acronymsmapTF {#1} {#2} {} } 218 | 219 | \NewDocumentCommand \acronymsmapF {+m+m} 220 | { \acronymsmapTF {#1} {} {#2} } 221 | 222 | \NewDocumentCommand \acronymsmap {+m} 223 | { \acronymsmapTF {#1} {} {} } 224 | 225 | \NewExpandableDocumentCommand \acrofield {mm} 226 | { \acro_property_get:nn {#1} {#2} } 227 | 228 | \NewDocumentCommand \acroprintfield {mm} 229 | { 230 | \acro_property_if_eq:nnTF {#2} {list} 231 | { 232 | \bool_if:NT \l__acro_upper_list_bool { \acro_upper: } 233 | \acro_write:en {#1} {#2} 234 | } 235 | { \acro_write:en {#1} {#2} } 236 | } 237 | 238 | \NewExpandableDocumentCommand \acroiffieldTF {+m+m+m+m} 239 | { \acro_property_if_set:nnTF {#1} {#2} {#3} {#4} } 240 | 241 | \NewDocumentCommand \acroifanyfieldTF {mm+m+m} 242 | { \acro_property_if_any:nnTF {#1} {#2} {#3} {#4} } 243 | 244 | \NewDocumentCommand \acroifallfieldsTF {mm+m+m} 245 | { \acro_property_if_all:nnTF {#1} {#2} {#3} {#4} } 246 | 247 | \NewExpandableDocumentCommand \acroifpagefieldTF {m} 248 | { \acro_if_pages:nTF {#1} } 249 | 250 | \NewDocumentCommand \acrowrite {m} 251 | { \acroprintfield { \AcronymID } {#1} } 252 | 253 | \NewDocumentCommand \acroshow {m} 254 | { \acro_property_show:en { \AcronymID } {#1} } 255 | 256 | \NewDocumentCommand \acrodonotuse {} 257 | { \acro_use_false: } 258 | 259 | \NewDocumentCommand \acroformat {mm} 260 | { \acro_format:enn { \AcronymID } {#1} {#2} } 261 | 262 | \NewDocumentCommand \acrogroupcite {} 263 | { 264 | \bool_if:NT \l__acro_cite_group_bool 265 | { 266 | \tl_set_eq:NN \l__acro_cite_pre_tl \l__acro_cite_between_tl 267 | \cs_set_eq:NN \__acro_cite_cmd:w \__acro_cite_group_cmd:w 268 | \acro_cite_if:neT { \l__acro_star_bool } { \AcronymID } 269 | { \acro_cite:e { \AcronymID } } 270 | } 271 | } 272 | 273 | \NewDocumentCommand \acrocite {} 274 | { \bool_set_true:N \l__acro_cite_always_bool } 275 | 276 | \NewExpandableDocumentCommand \acroifpropertyTF {m} 277 | { \acro_property_if_exist:nTF {#1} } 278 | 279 | \NewExpandableDocumentCommand \acroifpropertyT {m} 280 | { \acro_property_if_exist:nT {#1} } 281 | 282 | \NewExpandableDocumentCommand \acroifpropertyF {m} 283 | { \acro_property_if_exist:nF {#1} } 284 | 285 | \NewExpandableDocumentCommand \acroifbooleanTF {m} 286 | { \acro_boolean_property_if:enTF { \AcronymID } {#1} } 287 | 288 | \NewExpandableDocumentCommand \acroifbooleanT {m} 289 | { \acro_boolean_property_if:enT { \AcronymID } {#1} } 290 | 291 | \NewExpandableDocumentCommand \acroifbooleanF {m} 292 | { \acro_boolean_property_if:enF { \AcronymID } {#1} } 293 | 294 | \NewExpandableDocumentCommand \acroifTF {m} 295 | { \acro_property_if_set:enTF { \AcronymID } {#1} } 296 | \NewExpandableDocumentCommand \acroifT {m} 297 | { \acro_property_if_set:enT { \AcronymID } {#1} } 298 | \NewExpandableDocumentCommand \acroifF {m} 299 | { \acro_property_if_set:enF { \AcronymID } {#1} } 300 | 301 | \NewDocumentCommand \acroifanyTF {m+m+m} 302 | { \acro_property_if_any:enTF { \AcronymID } {#1} {#2} {#3} } 303 | \NewDocumentCommand \acroifanyT {m+m} 304 | { \acro_property_if_any:enTF { \AcronymID } {#1} {#2} {} } 305 | \NewDocumentCommand \acroifanyF {m+m} 306 | { \acro_property_if_any:enTF { \AcronymID } {#1} {} {#2} } 307 | 308 | \NewDocumentCommand \acroifallTF {m+m+m} 309 | { \acro_property_if_all:enTF { \AcronymID } {#1} {#2} {#3} } 310 | \NewDocumentCommand \acroifallT {m+m} 311 | { \acro_property_if_all:enTF { \AcronymID } {#1} {#2} {} } 312 | \NewDocumentCommand \acroifallF {m+m} 313 | { \acro_property_if_all:enTF { \AcronymID } {#1} {} {#2} } 314 | 315 | \NewDocumentCommand \acroifsingleTF {+m+m} 316 | { \acro_if_single:eTF { \AcronymID } {#1} {#2} } 317 | \NewDocumentCommand \acroifsingleT {+m} 318 | { \acro_if_single:eTF { \AcronymID } {#1} {} } 319 | \NewDocumentCommand \acroifsingleF {+m} 320 | { \acro_if_single:eTF { \AcronymID } {} {#1} } 321 | 322 | \NewDocumentCommand \acroiffirstTF {+m+m} 323 | { \acro_if_first:eTF { \AcronymID } {#1} {#2} } 324 | \NewDocumentCommand \acroiffirstT {+m} 325 | { \acro_if_first:eTF { \AcronymID } {#1} {} } 326 | \NewDocumentCommand \acroiffirstF {+m} 327 | { \acro_if_first:eTF { \AcronymID } {} {#1} } 328 | 329 | \NewDocumentCommand \acroiftagTF {m+m+m} 330 | { \acro_tag_if:enTF { \AcronymID } {#1} {#2} {#3} } 331 | \NewDocumentCommand \acroiftagT {m+m} 332 | { \acro_tag_if:enT { \AcronymID } {#1} {#2} } 333 | \NewDocumentCommand \acroiftagF {m+m} 334 | { \acro_tag_if:enF { \AcronymID } {#1} {#2} } 335 | 336 | \NewDocumentCommand \acropages {mm} 337 | { \acro_print_pages:enn { \AcronymID } {#1} {#2} } 338 | 339 | \NewDocumentCommand \acronopagerange {} 340 | { \acro_no_page_ranges:e { \AcroTemplateName } } 341 | 342 | \NewDocumentCommand \acroneedpages {} 343 | { \acro_need_pages: } 344 | 345 | \NewDocumentCommand \acropagefill {} 346 | { \acro_if_pages:eT { \AcronymID } { \tl_use:N \l__acro_pages_fill_tl } } 347 | 348 | \NewDocumentCommand \acrodotfill {} { \acro_dot_fill: } 349 | 350 | \NewExpandableDocumentCommand \acroifpagesTF {} 351 | { \acro_if_pages:eTF { \AcronymID } } 352 | 353 | \NewExpandableDocumentCommand \acroifpagesT {} 354 | { \acro_if_pages:eT { \AcronymID } } 355 | 356 | \NewExpandableDocumentCommand \acroifpagesF {} 357 | { \acro_if_pages:eF { \AcronymID } } 358 | 359 | \NewExpandableDocumentCommand \acroifchapterTF {} 360 | { \cs_if_exist:NTF \chapter } 361 | 362 | \NewExpandableDocumentCommand \acroifchapterT {} 363 | { \cs_if_exist:NT \chapter } 364 | 365 | \NewExpandableDocumentCommand \acroifchapterF {} 366 | { \cs_if_exist:NF \chapter } 367 | 368 | % -------------------------------------------------------------------------- 369 | \AcroModuleEnd 370 | -------------------------------------------------------------------------------- /code/acro.list.code.tex: -------------------------------------------------------------------------------- 1 | \AcroModule{list}{the list of acronyms} 2 | 3 | \bool_new:N \l__acro_list_display_all_bool 4 | \bool_new:N \l__acro_list_bool 5 | \bool_new:N \l__acro_list_local_bool 6 | 7 | \seq_new:N \g__acro_list_seq 8 | 9 | \tl_new:N \l__acro_list_tl 10 | 11 | \clist_new:N \l__acro_tag_include_clist 12 | \clist_new:N \l__acro_tag_exclude_clist 13 | \clist_new:N \l__acro_tag_add_clist 14 | 15 | \cs_new_protected:Npn \acro_list_choose_set: 16 | { 17 | \bool_if:NTF \l__acro_list_display_all_bool 18 | { \seq_gset_eq:NN \g__acro_list_seq \g_acro_acronyms_seq } 19 | { 20 | \seq_gclear:N \g__acro_list_seq 21 | \seq_map_inline:Nn \g_acro_acronyms_seq 22 | { 23 | \acro_if_single:nTF {##1} 24 | { 25 | \clist_set:Ne \l__acro_tmpa_clist 26 | { \acro_property_get:nn {##1} {tag} } 27 | \clist_map_inline:Nn \l__acro_tmpa_clist 28 | { 29 | \clist_if_in:NnT \l__acro_tag_add_clist {####1} 30 | {% acronym is included 31 | \seq_gput_right:Nn \g__acro_list_seq {##1} 32 | \clist_map_break: 33 | } 34 | } 35 | } 36 | { \seq_gput_right:Nn \g__acro_list_seq {##1} } 37 | } 38 | } 39 | } 40 | 41 | % -------------------------------------------------------------------------- 42 | % #1: filtered sequence 43 | % #2: sequence 44 | \cs_new_protected:Npn \__acro_list_filter:NN #1#2 45 | { 46 | \seq_clear:N #2 47 | \seq_clear:N \l__acro_tmpc_seq 48 | \bool_if:NF \l__acro_list_local_bool 49 | { \bool_set_true:N \l__acro_tmpb_bool } 50 | \seq_map_inline:Nn #1 51 | { 52 | \__acro_check_tags:Nn \l__acro_tmpa_bool {##1} 53 | \bool_lazy_and:nnT 54 | { \l__acro_list_local_bool } 55 | { 56 | \int_compare_p:nNn 57 | { \intarray_count:c {g__acro_##1_barriers_intarray} } > 0 58 | } 59 | { 60 | \bool_set_false:N \l__acro_tmpb_bool 61 | \int_compare:nNnT 62 | { \acro_barrier_usage:n {##1} } > 0 63 | { \bool_set_true:N \l__acro_tmpb_bool } 64 | } 65 | \bool_lazy_and:nnT { \l__acro_tmpa_bool } { \l__acro_tmpb_bool } 66 | { \seq_put_right:Nn #2 {##1} } 67 | } 68 | } 69 | 70 | % #1: boolean 71 | % #2: id 72 | \cs_new_protected:Npn \__acro_check_tags:Nn #1#2 73 | { 74 | \bool_set_false:N #1 75 | % get tags for acronym: 76 | \clist_set:Ne \l__acro_tmpa_clist 77 | { \acro_property_get:nn {#2} {tag} } 78 | \clist_if_empty:NTF \l__acro_tmpa_clist 79 | {% acronym does not have (a) tag(s) 80 | \clist_if_empty:NT \l__acro_tag_include_clist 81 | { \bool_set_true:N #1 } 82 | } 83 | {% acronym has (a) tag(s) 84 | \clist_if_empty:NTF \l__acro_tag_include_clist 85 | { \bool_set_true:N #1 } 86 | { 87 | \clist_map_inline:Nn \l__acro_tmpa_clist 88 | { 89 | \clist_if_in:NnT \l__acro_tag_include_clist {##1} 90 | {% acronym is included 91 | \bool_set_true:N #1 92 | \clist_map_break: 93 | } 94 | } 95 | } 96 | \bool_if:NT #1 97 | {% we only need to check if acronym is included: 98 | \clist_if_empty:NF \l__acro_tag_exclude_clist 99 | { 100 | \clist_map_inline:Nn \l__acro_tmpa_clist 101 | { 102 | \clist_if_in:NnT \l__acro_tag_exclude_clist {##1} 103 | {% acronym is excluded 104 | \bool_set_false:N #1 105 | \clist_map_break: 106 | } 107 | } 108 | } 109 | } 110 | } 111 | } 112 | 113 | % -------------------------------------------------------------------------- 114 | \prg_new_protected_conditional:Npnn \acro_acronyms_map:n #1 {T,F,TF} 115 | { 116 | \__acro_list_filter:NN \g__acro_list_seq \l__acro_tmpa_seq 117 | \seq_if_empty:NTF \l__acro_tmpa_seq 118 | { \prg_return_false: } 119 | { 120 | \seq_map_inline:Nn \l__acro_tmpa_seq {#1} 121 | \prg_return_true: 122 | } 123 | } 124 | 125 | \cs_new_protected:Npn \acro_list: 126 | { 127 | \group_begin: 128 | \bool_set_true:N \l__acro_list_bool 129 | \acro_list_choose_set: 130 | \cs_set_eq:NN \__acro_upper_case:n \__acro_list_upper_case:n 131 | \bool_if:NT \l__acro_sort_bool { \acro_list_sort: } 132 | \acro_template_use:nnV {0} {list} \l__acro_list_tl 133 | \group_end: 134 | } 135 | 136 | % -------------------------------------------------------------------------- 137 | \tl_new:N \l__acro_heading_tl 138 | \tl_new:N \l__acro_preamble_tl 139 | \tl_new:N \l__acro_postamble_tl 140 | 141 | \cs_new_protected:Npn \acro_heading: 142 | { \acro_template_use:nnV {0} {heading} \l__acro_heading_tl } 143 | 144 | \cs_new_protected:Npn \acro_preamble: 145 | { \tl_use:N \l__acro_preamble_tl } 146 | 147 | \cs_new_protected:Npn \acro_postamble: 148 | { \tl_use:N \l__acro_postamble_tl } 149 | 150 | \tl_new:N \l__acro_list_name_tl 151 | 152 | % -------------------------------------------------------------------------- 153 | \keys_define:nn {acro/list} 154 | { 155 | template .tl_set:N = \l__acro_list_tl , 156 | template .initial:n = description , 157 | sort .bool_set:N = \l__acro_sort_bool , 158 | sort .initial:n = true , 159 | display .choice: , 160 | display/all .code:n = \bool_set_true:N \l__acro_list_display_all_bool , 161 | display/used .code:n = \bool_set_false:N \l__acro_list_display_all_bool , 162 | display .initial:n = used , 163 | include .clist_set:N = \l__acro_tag_include_clist , 164 | exclude .clist_set:N = \l__acro_tag_exclude_clist , 165 | add .clist_set:N = \l__acro_tag_add_clist , 166 | local .bool_set:N = \l__acro_list_local_bool , 167 | heading .tl_set:N = \l__acro_heading_tl , 168 | preamble .tl_set:N = \l__acro_preamble_tl , 169 | preamble .initial:n = , 170 | postamble .tl_set:N = \l__acro_postamble_tl , 171 | postamble .initial:n = , 172 | name .tl_set:N = \l__acro_list_name_tl , 173 | name .initial:n = \acro_translate:n {list-name} , 174 | pages .meta:nn = {acro/pages} {#1} 175 | } 176 | 177 | \acro_if_komascript:TF 178 | { 179 | \cs_if_exist:NTF \chapter 180 | { \keys_set:nn {acro/list}{ heading = addchap* } } 181 | { \keys_set:nn {acro/list}{ heading = addsec* } } 182 | } 183 | { 184 | \cs_if_exist:NTF \chapter 185 | { \keys_set:nn {acro/list}{ heading = chapter* } } 186 | { \keys_set:nn {acro/list}{ heading = section* } } 187 | } 188 | 189 | % -------------------------------------------------------------------------- 190 | \AcroModuleEnd 191 | -------------------------------------------------------------------------------- /code/acro.locale.code.tex: -------------------------------------------------------------------------------- 1 | \AcroModule{locale}{language support} 2 | 3 | \RequirePackage{translations} 4 | 5 | % -------------------------------------------------------------------------- 6 | \msg_new:nnn {acro} {language-not-defined} 7 | { 8 | You~ chose~ the~ language~ `#1'~ which~ is~ not~ defined~ by~ acro.~ 9 | `english'~ is~ used~ instead.~ If~ you~ just~ mistyped~ try~ again!~ 10 | Otherwise~ contact~ the~ author~ and~ he'll~ probably~ add~ your~ language. 11 | } 12 | 13 | \msg_new:nnn {acro} {translation-value} 14 | { You~ need~ to~ give~ a~ value~ to~ `#1'~ \msg_line_context: } 15 | 16 | % -------------------------------------------------------------------------- 17 | \bool_new:N \l__acro_show_locale_bool 18 | \tl_new:N \l__acro_locale_format_tl 19 | 20 | % #1: property 21 | \prg_new_conditional:Npnn \acro_if_foreign:n #1 {p,T,F,TF} 22 | { 23 | \str_if_eq:nnTF {#1} {foreign} 24 | { \prg_return_true: } 25 | { \prg_return_false: } 26 | } 27 | 28 | % #1: id 29 | % #2: property 30 | \prg_new_conditional:Npnn \acro_if_locale:nn #1#2 {p,T,F,TF} 31 | { 32 | \acro_if_foreign:nTF {#2} 33 | { 34 | \bool_lazy_or:nnTF 35 | { \acro_property_if_set_p:nn {#1} {foreign-babel} } 36 | { \acro_property_if_set_p:nn {#1} {foreign-locale} } 37 | { \prg_return_true: } 38 | { \prg_return_false: } 39 | } 40 | { \prg_return_false: } 41 | } 42 | 43 | % #1: id 44 | % #2: property 45 | % #3: text 46 | \cs_new_protected:Npn \acro_locale:nnn #1#2#3 47 | { 48 | \acro_if_foreign:nTF {#2} 49 | { 50 | \acro_if_locale:nnTF {#1} {#2} 51 | { 52 | \bool_if:NTF \l__acro_list_bool 53 | { \bool_if:NT \l__acro_list_show_locale_bool } 54 | { \bool_if:NT \l__acro_show_locale_bool } 55 | { 56 | { 57 | \l__acro_locale_format_tl 58 | { 59 | \acro_property_if_set:nnTF {#1} {foreign-locale} 60 | { \acro_property_get:nn {#1} {foreign-locale} } 61 | { 62 | \baselanguage 63 | { \acro_property_get:nn {#1} {foreign-babel} } 64 | } 65 | } 66 | } 67 | :~ 68 | } 69 | \__acro_foreign_language:en 70 | { \str_lowercase:e { \acro_property_get:nn {#1} {foreign-babel} } } 71 | {#3} 72 | } 73 | {#3} 74 | } 75 | {#3} 76 | } 77 | 78 | \cs_new_protected:Npn \__acro_foreign_language:nn #1#2 79 | { 80 | \bool_lazy_or:nnTF 81 | { \acro_package_if_loaded_p:n {babel} } 82 | { \acro_package_if_loaded_p:n {polyglossia} } 83 | { \foreignlanguage {#1} {#2} } 84 | {#2} 85 | } 86 | \cs_generate_variant:Nn \__acro_foreign_language:nn {e} 87 | 88 | \keys_define:nn {acro/locale} 89 | { 90 | display .bool_set:N = \l__acro_show_locale_bool , 91 | display .initial:n = false , 92 | format .tl_set:N = \l__acro_locale_format_tl , 93 | format .initial:n = \em \text_titlecase_first:n 94 | } 95 | 96 | \keys_define:nn {acro/list/locale} 97 | { 98 | display .bool_set:N = \l__acro_list_show_locale_bool , 99 | display .initial:n = false 100 | } 101 | 102 | % -------------------------------------------------------------------------- 103 | 104 | \bool_new:N \l__acro_language_auto_bool 105 | \bool_set_true:N \l__acro_language_auto_bool 106 | % this token list will hold the chosen language for acro; since the 107 | % language is either chosen automatically or by option it is only available at 108 | % begin document 109 | \tl_new:N \l_acro_language_tl 110 | \tl_set:Nn \l_acro_language_tl {english} 111 | \tl_new:N \l__acro_current_language_tl 112 | 113 | % ---------------------------------------------------------------------------- 114 | \tl_const:Nn \c__acro_keyword_prefix_tl {acro-keyword-} 115 | \prop_new:N \g_acro_translations_prop 116 | 117 | % translate the key #1 118 | \cs_new:Npn \acro_translate:n #1 119 | { 120 | \bool_if:NTF \l__acro_language_auto_bool 121 | { \GetTranslation { \c__acro_keyword_prefix_tl #1 } } 122 | { 123 | \GetTranslationFor 124 | { \l_acro_language_tl } 125 | { \c__acro_keyword_prefix_tl #1 } 126 | } 127 | } 128 | 129 | \acro_at_begin_document:n 130 | { 131 | \bool_if:NTF \l__acro_language_auto_bool 132 | { 133 | \tl_if_exist:NTF \c_trnslt_current_language_tl 134 | { 135 | \tl_set_eq:NN \l_acro_language_tl 136 | \c_trnslt_current_language_tl 137 | } 138 | { 139 | \tl_set:Nx \l_acro_language_tl 140 | { \@trnslt@language{\@trnslt@current@language} } 141 | } 142 | } 143 | { 144 | \tl_set_eq:NN 145 | \l_acro_language_tl 146 | \l__acro_current_language_tl 147 | } 148 | } 149 | 150 | % ---------------------------------------------------------------------------- 151 | % #1: language 152 | % #2: keyword 153 | % #3: translation 154 | \cs_new_protected:Npn \acro_declare_translation:nnn #1#2#3 155 | { 156 | \declaretranslation 157 | {#1} 158 | { \c__acro_keyword_prefix_tl #2 } 159 | {#3} 160 | \prop_gput:Nnn \g_acro_translations_prop {#2(#1)} {#3} 161 | } 162 | \cs_generate_variant:Nn \acro_declare_translation:nnn {V,VnV} 163 | 164 | % #1: key 165 | % #2: csv list: { = , = } 166 | \cs_new_protected:Npn \acro_declare_translations:nn #1#2 167 | { 168 | \cs_set:Npn \__acro_declare_translation_aux:n ##1 169 | { \msg_error:nnn {acro} {translation-value} {##1} } 170 | \cs_set:Npn \__acro_declare_translation_aux:nn ##1##2 171 | { \acro_declare_translation:nnn {##1} {#1} {##2} } 172 | \keyval_parse:NNn 173 | \__acro_declare_translation_aux:n 174 | \__acro_declare_translation_aux:nn 175 | {#2} 176 | } 177 | 178 | % #1: language 179 | % #2: csv list: { = , = } 180 | \cs_new_protected:Npn \acro_add_translations:nn #1#2 181 | { 182 | \cs_set:Npn \__acro_declare_translation_aux:n ##1 183 | { \msg_error:nnn {acro} {translation-value} {##1} } 184 | \cs_set:Npn \__acro_declare_translation_aux:nn ##1##2 185 | { \acro_declare_translation:nnn {#1} {##1} {##2} } 186 | \keyval_parse:NNn 187 | \__acro_declare_translation_aux:n 188 | \__acro_declare_translation_aux:nn 189 | {#2} 190 | } 191 | 192 | % within the loop: 193 | % #1: keyword 194 | % #2: language 195 | % #3: translation 196 | \cs_new_protected:Npn \__acro_for_all_translations_do:n #1 197 | { 198 | \cs_set:Npn \__acro_parse_translate_list_entry:nnn ##1##2##3 {#1} 199 | \prop_map_inline:Nn \g_acro_translations_prop 200 | { \__acro_parse_translate_list_entry:www ##1 \q_mark ##2 \q_stop } 201 | } 202 | 203 | % the purpose of the following is to easy documentation: 204 | \cs_new:Npn \__acro_parse_translate_list_entry:nnn #1#2#3 {} 205 | 206 | \cs_new_protected:Npn \__acro_parse_translate_list_entry:www #1(#2)\q_mark#3\q_stop 207 | { \__acro_parse_translate_list_entry:nnn {#1} {#2} {#3} } 208 | 209 | % ---------------------------------------------------------------------------- 210 | 211 | \keys_define:nn {acro} 212 | { 213 | language .value_required:n = true , 214 | language .code:n = 215 | \str_case:nnF {#1} 216 | { {auto} { \bool_set_true:N \l__acro_language_auto_bool } } 217 | { 218 | \bool_set_false:N \l__acro_language_auto_bool 219 | \tl_set:Nn \l__acro_current_language_tl {#1} 220 | } , 221 | language .initial:n = auto 222 | } 223 | 224 | % -------------------------------------------------------------------------- 225 | \AcroModuleEnd 226 | -------------------------------------------------------------------------------- /code/acro.pages.code.tex: -------------------------------------------------------------------------------- 1 | \AcroModule{pages}{recording and printing of pages} 2 | % ---------------------------------------------------------------------------- 3 | % record page numbers: 4 | \msg_new:nnn {acro} {no-page-range} 5 | { 6 | The~ list~ template~ `#1'~ cannot~ display~ a~ page~ range. 7 | } 8 | 9 | \msg_new:nnn {acro} {threshold} 10 | { The~ sequentes~ threshold~ needs~ to~ be~ at~ least~ 3. } 11 | 12 | % #1: id 13 | \cs_new_protected:Npn \acro_record_page:n #1 14 | { 15 | \__acro_record_page:n {#1} 16 | \hook_gput_code:nnn {enddocument} {acro} 17 | { 18 | \seq_gremove_duplicates:c {g__acro_#1_pages_seq} 19 | \acro_property_set:nnx {#1} {pages} 20 | { \seq_use:cn {g__acro_#1_pages_seq} {|} } 21 | } 22 | } 23 | 24 | \cs_new_protected:Npn \__acro_record_page:n #1 25 | { 26 | \iow_shipout_x:Nn \@auxout 27 | { 28 | \token_to_str:N \ACRO {recordpage} 29 | {#1} 30 | { \int_use:N \g_shipout_totalpages_int } 31 | { \int_use:N \g_acro_barrier_int } 32 | { \thepage } 33 | } 34 | } 35 | 36 | \group_begin: 37 | \char_set_catcode_other:N \@ 38 | 39 | \__acro_auxlist_field_new:cpn {recordpage} #1#2#3#4 40 | { \seq_gput_right:ce {g__acro_#1_pages_seq} {#2@#3@#4} } 41 | 42 | \cs_new:Npn \__acro_page_name:w #1@#2@#3 \q_stop 43 | { 44 | \acro_package_if_loaded:nTF {hyperref} 45 | { \exp_not:N \hyperpage { \exp_not:n {#3} } } 46 | { \exp_not:n {#3} } 47 | } 48 | 49 | \cs_new:Npn \__acro_absolute_page:w #1@#2@#3 \q_stop {#1} 50 | 51 | \cs_new:Npn \__acro_barrier:w #1@#2@#3 \q_stop {#2} 52 | 53 | \group_end: 54 | 55 | \acro_at_begin_document:n 56 | { \intarray_new:Nn \g__acro_pages_intarray { \PreviousTotalPages } } 57 | 58 | % #1: id 59 | % #2: one page 60 | % #3: more than one page 61 | \cs_new_protected:Npn \acro_print_pages:nnn #1#2#3 62 | { 63 | \acro_if_pages:nT {#1} 64 | { 65 | \bool_if:NTF \l__acro_pages_all_bool 66 | { 67 | \bool_if:NTF \l__acro_pages_name_display_bool 68 | { \acro_print_page_ranges:nnn {#1} {#2} {#3} } 69 | { \acro_print_page_ranges:nnn {#1} {} {} } 70 | } 71 | { 72 | \bool_if:NT \l__acro_pages_name_display_bool {#2} 73 | \acro_print_first_page:n {#1} 74 | } 75 | } 76 | } 77 | \cs_generate_variant:Nn \acro_print_pages:nnn {e} 78 | 79 | % #1: id 80 | \cs_set_protected:Npn \acro_print_first_page:n #1 81 | { 82 | \seq_set_split:Nnx \l__acro_tmpa_seq {|} 83 | { \acro_property_get:nn {#1} {pages} } 84 | \seq_remove_all:Nn \l__acro_tmpa_seq {} 85 | \seq_if_empty:NF \l__acro_tmpa_seq 86 | { 87 | \use:e 88 | { 89 | \exp_last_unbraced:Ne 90 | \__acro_page_name:w 91 | { \seq_item:Nn \l__acro_tmpa_seq {1} } 92 | \q_stop 93 | } 94 | } 95 | } 96 | 97 | % #1: id 98 | % #2: one page 99 | % #3: more than one page 100 | \cs_set_protected:Npn \acro_print_page_ranges:nnn #1#2#3 101 | { 102 | \seq_set_split:Nnx \l__acro_tmpa_seq {|} 103 | { \acro_property_get:nn {#1} {pages} } 104 | \seq_remove_all:Nn \l__acro_tmpa_seq {} 105 | \intarray_gzero:N \g__acro_pages_intarray 106 | \seq_map_inline:Nn \l__acro_tmpa_seq 107 | { 108 | \intarray_gset:Nnn \g__acro_pages_intarray 109 | { \__acro_absolute_page:w ##1 \q_stop } 110 | { 111 | \bool_if:NTF \l__acro_list_local_bool 112 | { 113 | \int_compare:nNnTF 114 | { \__acro_barrier:w ##1 \q_stop } 115 | = 116 | \g_acro_barrier_int 117 | {1} 118 | {0} 119 | } 120 | {1} 121 | } 122 | } 123 | \bool_if:NT \l__acro_list_local_bool 124 | { 125 | \seq_clear:N \l__acro_tmpb_seq 126 | \seq_map_inline:Nn \l__acro_tmpa_seq 127 | { 128 | \int_compare:nNnT 129 | { \__acro_barrier:w ##1 \q_stop } 130 | = 131 | \g_acro_barrier_int 132 | { \seq_put_right:Nn \l__acro_tmpb_seq {##1} } 133 | } 134 | \seq_set_eq:NN \l__acro_tmpa_seq \l__acro_tmpb_seq 135 | } 136 | \seq_clear:N \l__acro_tmpb_seq 137 | \int_zero:N \l__acro_tmpb_int 138 | \seq_map_inline:Nn \l__acro_tmpa_seq 139 | { 140 | % the current page 141 | \int_set:Nn \l__acro_tmpa_int 142 | { \__acro_absolute_page:w ##1 \q_stop } 143 | \int_compare:nNnTF \l__acro_tmpa_int = 1 144 | { % first page, start range 145 | \seq_put_right:Ne \l__acro_tmpb_seq 146 | { \__acro_page_name:w ##1 \q_stop } 147 | \int_incr:N \l__acro_tmpb_int 148 | } 149 | { % not first page 150 | \int_compare:nNnTF 151 | { 152 | \intarray_item:Nn \g__acro_pages_intarray 153 | { \l__acro_tmpa_int - 1 } 154 | } 155 | = 0 156 | { % start range 157 | \int_zero:N \l__acro_tmpb_int 158 | \seq_put_right:Ne \l__acro_tmpb_seq 159 | { \__acro_page_name:w ##1 \q_stop } 160 | \int_incr:N \l__acro_tmpb_int 161 | } 162 | { % continue range 163 | \int_compare:nNnTF 164 | \l__acro_tmpa_int = { \intarray_count:N \g__acro_pages_intarray } 165 | { % last page, range ended 166 | \__acro_finish_range:Nnn \l__acro_tmpb_seq 167 | { \l__acro_tmpb_int } 168 | {##1} 169 | \int_zero:N \l__acro_tmpb_int 170 | } 171 | { % not last page 172 | \int_compare:nNnTF 173 | { 174 | \intarray_item:Nn \g__acro_pages_intarray 175 | { \l__acro_tmpa_int + 1 } 176 | } 177 | = 0 178 | { % range ended 179 | \__acro_finish_range:Nnn \l__acro_tmpb_seq 180 | { \l__acro_tmpb_int } 181 | {##1} 182 | \int_zero:N \l__acro_tmpb_int 183 | } 184 | {% continue range 185 | \int_incr:N \l__acro_tmpb_int 186 | } 187 | } 188 | } 189 | } 190 | } 191 | \int_compare:nNnTF { \seq_count:N \l__acro_tmpb_seq } = 1 {#2} {#3} 192 | \seq_use:Nn \l__acro_tmpb_seq { \l__acro_pages_sep_tl } 193 | } 194 | 195 | % #1: sequence 196 | % #2: range length 197 | % #3: page property entry 198 | \cs_new_protected:Npn \__acro_finish_range:Nnn #1#2#3 199 | { 200 | \seq_pop_right:NN #1 \l__acro_tmpa_tl 201 | \int_compare:nNnTF {#2} > 1 202 | { 203 | \bool_lazy_and:nnTF 204 | { \l__acro_seq_use_bool } 205 | { \int_compare_p:nNn {#2} < \l__acro_pages_seq_threshold_int } 206 | { 207 | \seq_put_right:Ne \l__acro_tmpb_seq 208 | { 209 | \exp_not:V \l__acro_tmpa_tl 210 | \exp_not:V \l__acro_pages_seq_pre_tl 211 | \acro_translate:n {sequentes} 212 | } 213 | } 214 | { 215 | \seq_put_right:Ne \l__acro_tmpb_seq 216 | { 217 | \exp_not:V \l__acro_tmpa_tl 218 | -- 219 | \__acro_page_name:w #3 \q_stop 220 | } 221 | } 222 | } 223 | { 224 | \bool_if:NTF \l__acro_seq_use_bool 225 | { 226 | \seq_put_right:Ne \l__acro_tmpb_seq 227 | { 228 | \exp_not:V \l__acro_tmpa_tl 229 | \exp_not:V \l__acro_pages_seq_pre_tl 230 | \acro_translate:n {sequens} 231 | } 232 | } 233 | { 234 | \seq_put_right:Ne \l__acro_tmpb_seq 235 | { \exp_not:V \l__acro_tmpa_tl } 236 | \seq_put_right:Ne \l__acro_tmpb_seq 237 | { \__acro_page_name:w #3 \q_stop } 238 | } 239 | } 240 | } 241 | 242 | \bool_new:N \l__acro_pages_all_bool 243 | \bool_new:N \l__acro_pages_display_bool 244 | \bool_new:N \l__acro_seq_use_bool 245 | 246 | % #1: id 247 | \prg_new_conditional:Npnn \acro_if_pages:n #1 {p,T,F,TF} 248 | { 249 | \bool_lazy_and:nnTF 250 | { \l__acro_pages_display_bool } 251 | { 252 | \bool_lazy_and_p:nn 253 | { \acro_attribute_if_set_p:nn {pages} {#1} } 254 | { 255 | \bool_lazy_or_p:nn 256 | { \l__acro_list_display_all_bool } 257 | { !\acro_if_single_p:n {#1} } 258 | } 259 | } 260 | { \prg_return_true: } 261 | { \prg_return_false: } 262 | } 263 | \prg_generate_conditional_variant:Nnn \acro_if_pages:n {e} {p,T,F,TF} 264 | 265 | % #1: style name 266 | \cs_new_protected:Npn \acro_no_page_ranges:n #1 267 | { 268 | \bool_if:NT \l__acro_pages_all_bool 269 | { \msg_warning:nnn {acro} {no-page-range} {#1} } 270 | \bool_set_false:N \l__acro_pages_all_bool 271 | } 272 | \cs_generate_variant:Nn \acro_no_page_ranges:n {e} 273 | 274 | \cs_new_protected:Npn \acro_need_pages: 275 | { \bool_set_true:N \l__acro_pages_display_bool } 276 | 277 | \tl_new:N \l__acro_pages_fill_tl 278 | \tl_new:N \l__acro_pages_sep_tl 279 | \tl_new:N \l__acro_pages_seq_pre_tl 280 | 281 | \int_new:N \l__acro_pages_seq_threshold_int 282 | 283 | % ---------------------------------------------------------------------------- 284 | \cs_new_protected:Npn \acro_dot_fill: 285 | { 286 | \leaders \hbox 287 | { 288 | $\m@th 289 | \mkern \@dotsep mu 290 | \hbox {.} 291 | \mkern \@dotsep mu$ 292 | } 293 | \hfill 294 | } 295 | 296 | \hook_gput_code:nnn {begindocument} {xsim} 297 | { 298 | \cs_if_exist:NT \cftdotfill 299 | { \cs_set_protected:Npn \acro_dot_fill: { \cftdotfill { \cftdotsep } } } 300 | } 301 | 302 | \keys_define:nn {acro/pages} 303 | { 304 | display .choice: , 305 | display / all .code:n = 306 | \bool_set_true:N \l__acro_pages_display_bool 307 | \bool_set_true:N \l__acro_pages_all_bool , 308 | display / first .code:n = 309 | \bool_set_true:N \l__acro_pages_display_bool 310 | \bool_set_false:N \l__acro_pages_all_bool , 311 | display / none .code:n = 312 | \bool_set_false:N \l__acro_pages_display_bool , 313 | seq / use .bool_set:N = \l__acro_seq_use_bool , 314 | seq / use .initial:n = true , 315 | seq / pre .tl_set:N = \l__acro_pages_seq_pre_tl , 316 | seq / pre .initial:n = \, , 317 | seq / threshold .code:n = 318 | \int_compare:nNnTF {#1} < 3 319 | { \msg_error:nn {acro} {threshold} } 320 | { \int_set:Nn \l__acro_pages_seq_threshold_int {#1} } , 321 | seq / threshold .initial:n = 3 , 322 | fill .tl_set:N = \l__acro_pages_fill_tl , 323 | fill .initial:n = \acro_dot_fill: , 324 | sep .tl_set:N = \l__acro_pages_sep_tl , 325 | sep .initial:n = {,~} , 326 | name .bool_set:N = \l__acro_pages_name_display_bool , 327 | name .initial:n = false 328 | } 329 | 330 | % ---------------------------------------------------------------------------- 331 | \AcroModuleEnd 332 | -------------------------------------------------------------------------------- /code/acro.patch.code.tex: -------------------------------------------------------------------------------- 1 | \AcroModule{patch}{patch other code} 2 | 3 | \msg_new:nnn {acro} {patch} 4 | { Patching~ `#1'~ failed.~ Please~ contact~ the~ acro~ author. } 5 | 6 | \RequirePackage {etoolbox} 7 | 8 | \cs_new_protected:Npn \acro_new_patch:n #1 9 | { 10 | \bool_new:c {l__acro_patch_#1_bool} 11 | \keys_define:nn 12 | {acro} 13 | { 14 | patch / #1 .bool_set:c = {l__acro_patch_#1_bool} , 15 | patch / #1 .initial:n = true 16 | } 17 | } 18 | 19 | \prg_new_conditional:Npnn \acro_if_patch:n #1 {T,F,TF} 20 | { 21 | \cs_if_exist:cTF {l__acro_patch_#1_bool} 22 | { 23 | \bool_if:cTF {l__acro_patch_#1_bool} 24 | { \prg_return_true: } 25 | { \prg_return_false: } 26 | } 27 | { \prg_return_false: } 28 | } 29 | 30 | \acro_new_patch:n {floats} 31 | \acro_new_patch:n {lists} 32 | \acro_new_patch:n {tabularx} 33 | \acro_new_patch:n {tabu} 34 | \acro_new_patch:n {ltxtable} 35 | \acro_new_patch:n {caption} 36 | \acro_new_patch:n {maketitle} 37 | \acro_new_patch:n {longtable} 38 | 39 | \hook_gput_code:nnn {begindocument/before} {acro} 40 | { 41 | % maketitle: 42 | \acro_if_patch:nT {maketitle} 43 | { 44 | \pretocmd \maketitle 45 | { \acswitchoff } 46 | {} 47 | { \msg_error:nnn {acro} {patch} {maketitle} } 48 | \apptocmd \maketitle 49 | { \acswitchon } 50 | {} 51 | { \msg_error:nnn {acro} {patch} {maketitle} } 52 | } 53 | % floats: 54 | \acro_if_patch:nT {floats} 55 | { 56 | \apptocmd \@floatboxreset 57 | { \acswitchoff } 58 | {} 59 | { \msg_error:nnn {acro} {patch} {floats} } 60 | } 61 | % contents lists: 62 | \acro_if_patch:nT {lists} 63 | { 64 | \addtocontents {toc} { \acswitchoff } 65 | \addtocontents {lof} { \acswitchoff } 66 | \addtocontents {lot} { \acswitchoff } 67 | } 68 | % caption package: 69 | \acro_if_patch:nT {caption} 70 | { 71 | \cs_if_exist:NT \caption@prepareslc 72 | { \tl_gput_right:Nn \caption@prepareslc { \acswitchoff } } 73 | } 74 | % tables: 75 | % * tabularx 76 | \acro_if_patch:nT {tabularx} 77 | { 78 | \cs_if_exist:NT \TX@trial 79 | { 80 | \patchcmd \TX@trial 81 | { \let\hbadness\@tempcnta } 82 | { \acswitchoff\let\hbadness\@tempcnta } 83 | {} 84 | { \msg_error:nnn {acro} {patch} {tabularx} } 85 | } 86 | } 87 | % * ltxtable 88 | \acro_if_patch:nT {ltxtable} 89 | { 90 | \cs_if_exist:NT \LTXtable 91 | { 92 | \patchcmd \LTXtable 93 | { \input } 94 | { \acswitchoff\input } 95 | {} 96 | { \msg_error:nnn {acro} {patch} {ltxtable} } 97 | } 98 | } 99 | % * tabu 100 | \acro_if_patch:nT {tabu} 101 | { 102 | \cs_if_exist:NT \tabuDisableCommands 103 | { \tabuDisableCommands { \acswitchoff } } 104 | } 105 | % * longtable 106 | \acro_if_patch:nT {longtable} 107 | { 108 | \cs_if_exist:NT \endlongtable 109 | { 110 | \patchcmd \endlongtable 111 | { \ifx \LT@save@row \LT@@save@row \else } 112 | { \ifx \LT@save@row \LT@@save@row \else \acswitchoff } 113 | {} 114 | { \msg_error:nnn {acro} {patch} {longtable} } 115 | } 116 | } 117 | } 118 | 119 | \AcroModuleEnd 120 | -------------------------------------------------------------------------------- /code/acro.pdfsupport.code.tex: -------------------------------------------------------------------------------- 1 | \AcroModule{pdfsupport}{support for bookmarks and accessibility} 2 | 3 | \msg_new:nnn {acro} {pdf-template-exists} 4 | { The~ pdfstring~ template~ `#1'~ already~ exists~ \msg_line_context: } 5 | 6 | \msg_new:nnn {acro} {pdf-template-undefined} 7 | { The~ pdfstring~ template~ `#1'~ is~ not~ defined~ \msg_line_context: } 8 | 9 | \msg_new:nnn {acro} {local-links} 10 | { 11 | You~ are~ using~ the~ option~ `make-links'~ in~ combination~ with~ local~ 12 | acronym~ lists.~ Please~ make~ sure~ to~ also~ set \\ 13 | \ \ \ \ barriers/single~ =~ true \\ 14 | for~ referencing~ only~ existing~ and~ unique~ links. 15 | } 16 | 17 | % -------------------------------------------------------------------------- 18 | % hyper linking 19 | \bool_new:N \l__acro_hyperref_use_bool 20 | \bool_new:N \l__acro_link_only_first_bool 21 | \bool_new:N \l__acro_link_back_bool 22 | 23 | \cs_new_eq:NN \__acro_hyper_target:nn \use_ii:nn 24 | \cs_new_eq:NN \__acro_hyper_link:nn \use_ii:nn 25 | \cs_new_eq:NN \__acro_hyper_back_target:nn \use_ii:nn 26 | \cs_new_eq:NN \__acro_hyper_back_link:nn \use_ii:nn 27 | 28 | \cs_generate_variant:Nn \__acro_hyper_target:nn {e} 29 | \cs_generate_variant:Nn \__acro_hyper_link:nn {e} 30 | \cs_generate_variant:Nn \__acro_hyper_back_target:nn {e} 31 | \cs_generate_variant:Nn \__acro_hyper_back_link:nn {e} 32 | 33 | \cs_new_protected:Npn \__acro_activate_hyperref_support: 34 | { 35 | \bool_lazy_and:nnT 36 | { \acro_package_if_loaded_p:n {hyperref} } 37 | { \l__acro_hyperref_use_bool } 38 | { 39 | \sys_if_engine_xetex:TF 40 | { 41 | \cs_set:Npn \__acro_hyper_link:nn ##1##2 42 | { \hyperlink {##1} { \XeTeXLinkBox {##2} } } 43 | } 44 | { \cs_set_eq:NN \__acro_hyper_link:nn \hyperlink } 45 | \cs_set_protected:Npn \__acro_hyper_target:nn ##1##2 46 | { \Hy@raisedlink { \hypertarget {##1} { } } ##2 } 47 | \cs_set_eq:NN \__acro_hyper_back_link:nn \__acro_hyper_link:nn 48 | \cs_set_eq:NN \__acro_hyper_back_target:nn \__acro_hyper_target:nn 49 | } 50 | } 51 | 52 | % #1: id 53 | % #2: property 54 | % #3: text 55 | \cs_new_protected:Npn \__acro_make_link:nnn #1#2#3 56 | { 57 | \acro_if_short:nTF {#2} 58 | { 59 | \bool_lazy_all:nTF 60 | { 61 | { \acro_package_if_loaded_p:n {hyperref} } 62 | { \l__acro_hyperref_use_bool } 63 | { 64 | \bool_lazy_or_p:nn 65 | { \l__acro_list_display_all_bool } 66 | { !\acro_if_single_p:n {#1} } 67 | } 68 | { 69 | \bool_lazy_or_p:nn 70 | { !\l__acro_link_only_first_bool } 71 | { \l__acro_link_only_first_bool && \acro_if_first_p:n {#1} } 72 | } 73 | } 74 | { 75 | \bool_lazy_and:nnTF 76 | { \l__acro_list_bool } 77 | { \int_compare_p:nNn { \l_acro_nest_level_int } = 0 } 78 | { 79 | \__acro_hyper_target:en 80 | { 81 | acro : #1 82 | \bool_lazy_and:nnT 83 | { \l__acro_list_local_bool } 84 | { \l__acro_usage_local_bool } 85 | { : \int_use:N \g_acro_barrier_int } 86 | } 87 | {#3} 88 | } 89 | { 90 | \__acro_hyper_link:en 91 | { 92 | acro : #1 93 | \bool_if:NT \l__acro_usage_local_bool 94 | { : \int_use:N \g_acro_barrier_int } 95 | } 96 | { \phantom {#3} } 97 | \__acro_color_link:n { \hbox_overlap_left:n {#3} } 98 | } 99 | } 100 | {#3} 101 | } 102 | {#3} 103 | } 104 | 105 | \acro_at_begin_document:n 106 | { 107 | \bool_if:nT 108 | { 109 | \l__acro_hyperref_use_bool && 110 | \l__acro_barriers_bool && 111 | ! \l__acro_usage_local_bool 112 | } 113 | { \msg_warning:nn {acro} {local-links} } 114 | } 115 | 116 | % #1: text 117 | \cs_new:Npn \__acro_color_link:n #1 118 | { 119 | \bool_lazy_and:nnTF 120 | { \cs_if_exist_p:N \hypersetup } 121 | { 122 | \bool_lazy_or_p:nn 123 | { \legacy_if_p:n {Hy@colorlinks} } 124 | { \legacy_if_p:n {Hy@ocgcolorlinks} } 125 | } 126 | { \textcolor { \@linkcolor } {#1} } 127 | {#1} 128 | } 129 | 130 | \acro_at_begin_document:n 131 | { 132 | \__acro_activate_hyperref_support: 133 | \cs_if_exist:NF \textcolor { \cs_new_eq:NN \textcolor \use_ii:nn } 134 | } 135 | 136 | \keys_define:nn {acro} 137 | { 138 | make-links .bool_set:N = \l__acro_hyperref_use_bool , 139 | make-links .initial:n = false , 140 | link-only-first .bool_set:N = \l__acro_link_only_first_bool , 141 | link-only-first .initial:n = false 142 | } 143 | 144 | % -------------------------------------------------------------------------- 145 | % accessibility support 146 | \bool_new:N \l__acro_accsupp_bool 147 | \bool_new:N \l__acro_use_accsupp_bool 148 | \tl_new:N \l__acro_accsupp_options_tl 149 | \tl_new:N \l__acro_accsupp_method_tl 150 | 151 | % #1: copied text 152 | % #2: printed text 153 | \cs_new_protected:Npn \__acro_accsupp:nn #1#2 154 | { 155 | \bool_if:NTF \l__acro_accsupp_bool 156 | { 157 | \int_compare:nNnTF { \l_acro_nest_level_int } > 1 158 | {#2} 159 | { 160 | \__acro_do_accsupp:Vnn 161 | \l__acro_acc_supp_options_tl 162 | {#1} 163 | {#2} 164 | } 165 | } 166 | {#2} 167 | } 168 | \cs_generate_variant:Nn \__acro_accsupp:nn {ee} 169 | 170 | % #1: options 171 | % #2: copied text 172 | % #3: printed text 173 | \cs_new_protected:Npn \__acro_do_accsupp:nnn #1#2#3 174 | { 175 | \BeginAccSupp { method = \l__acro_accsupp_method_tl , ActualText = {#2} , #1 } 176 | #3 177 | \EndAccSupp { } 178 | } 179 | \cs_generate_variant:Nn \__acro_do_accsupp:nnn {V} 180 | 181 | \acro_at_begin_document:n 182 | { 183 | \bool_lazy_all:nT 184 | { 185 | { \acro_package_if_loaded_p:n {accsupp} } 186 | { \acro_package_if_loaded_p:n {hyperref} } 187 | { \l__acro_use_accsupp_bool } 188 | } 189 | { \bool_set_true:N \l__acro_accsupp_bool } 190 | } 191 | 192 | \keys_define:nn {acro/accsupp} 193 | { 194 | use .code:n = 195 | \str_case:nnTF {#1} 196 | { {true} {} {false} {} } 197 | { \use:c {bool_set_#1:N} \l__acro_use_accsupp_bool } 198 | { \msg_error:nnn {kernel} {boolean-values-only} {group} } , 199 | use .initial:n = true , 200 | options .tl_set:N = \l__acro_acc_supp_options_tl , 201 | options .initial:n = , 202 | method .tl_set:N = \l__acro_accsupp_method_tl , 203 | method .initial:n = pdfstringdef 204 | } 205 | 206 | % -------------------------------------------------------------------------- 207 | % pdf comments a.k.a. tooltips 208 | \bool_new:N \l__acro_pdfcomment_use_bool 209 | 210 | % #1: id 211 | % #2: property 212 | % #3: text 213 | \cs_new:Npn \__acro_pdf_comment:nnn #1#2#3 214 | { 215 | \bool_lazy_all:nTF 216 | { 217 | { \l__acro_pdfcomment_use_bool } 218 | { \acro_property_if_set_p:nn {#1} {pdfcomment} } 219 | { \acro_if_short_p:n {#2} } 220 | } 221 | { 222 | \__acro_pdf_comment_cmd:ee 223 | {#3} 224 | { \acro_property_get:nn {#1} {pdfcomment} } 225 | } 226 | {#3} 227 | } 228 | 229 | \cs_new:Npn \__acro_pdf_comment_cmd:nn #1#2 {#1} 230 | \cs_generate_variant:Nn \__acro_pdf_comment_cmd:nn {ee} 231 | 232 | \keys_define:nn {acro/pdfcomments} 233 | { 234 | use .bool_set:N = \l__acro_pdfcomment_use_bool , 235 | use .initial:n = false , 236 | cmd .cs_set_protected:Np = \__acro_pdf_comment_cmd:nn #1#2 , 237 | cmd .initial:n = \pdftooltip {#1} {#2} 238 | } 239 | 240 | % -------------------------------------------------------------------------- 241 | % expandable templates for use in pdfstrings 242 | \prg_new_conditional:Npnn \acro_if_star_gobble:n #1 {TF} 243 | { 244 | \if_meaning:w *#1 245 | \prg_return_true: 246 | \else: 247 | \prg_return_false: 248 | \fi: 249 | } 250 | 251 | % #1: name 252 | % #2: code 253 | \cs_new_protected:Npn \acro_pdfstring_template_new:nn #1#2 254 | { 255 | \cs_if_exist:cTF {____acro:pdfstring:template:#1} 256 | { \msg_error:nnn {acro} {pdf-template-exists} {#1} } 257 | { \cs_new:cpn {____acro:pdfstring:template:#1} ##1 {#2} } 258 | } 259 | 260 | % #1: name 261 | % #2: code 262 | \cs_new_protected:Npn \acro_pdfstring_template_set:nn #1#2 263 | { 264 | \cs_if_exist:cTF {____acro:pdfstring:template:#1} 265 | { \cs_set:cpn {____acro:pdfstring:template:#1} ##1 {#2} } 266 | { \cs_new:cpn {____acro:pdfstring:template:#1} ##1 {#2} } 267 | } 268 | 269 | % #1: name 270 | % #2: name to be let to 271 | \cs_new_protected:Npn \acro_pdfstring_template_let:nn #1#2 272 | { 273 | \cs_if_exist:cTF {____acro:pdfstring:template:#2} 274 | { 275 | \cs_set_eq:cc 276 | {____acro:pdfstring:template:#1} 277 | {____acro:pdfstring:template:#2} 278 | } 279 | { \msg_error:nnn {acro} {pdf-template-undefined} {#2} } 280 | } 281 | 282 | % #1: name 283 | % #2: id 284 | \cs_new:Npn \acro_pdfstring_template:nn #1#2 285 | { 286 | \cs_if_exist:cTF {____acro:pdfstring:template:#1} 287 | { \use:c {____acro:pdfstring:template:#1} {#2} } 288 | { \msg_expandable_error:nnn {acro} {pdf-template-undefined} {#1} } 289 | } 290 | 291 | % #1: cs 292 | % #2: template 293 | \cs_new_protected:Npn \acro_set_pdf_cs:Nn #1#2 294 | { 295 | \cs_set:Npn #1 ##1 296 | { 297 | \acro_if_star_gobble:nTF {##1} 298 | { \acro_pdfstring_template:nn {#2} } 299 | { \acro_pdfstring_template:nn {#2} {##1} } 300 | } 301 | } 302 | 303 | % #1: id 304 | % #2: property 305 | \cs_new:Npn \__acro_pdfstring_plural:nn #1#2 306 | { 307 | \acro_property_get_if_set:nnF {#1} {#2-plural-form} 308 | { 309 | \str_if_eq:nnTF {#2} {short} 310 | { \acro_property_get:nn {#1} {pdfstring} } 311 | { \acro_property_get:nn {#1} {#2} } 312 | \acro_property_get:nn {#1} {#2-plural} 313 | } 314 | } 315 | 316 | % #1: id 317 | % #2: property 318 | \cs_new:Npn \__acro_pdfstring_indefinite:nn #1#2 319 | { 320 | \acro_property_get_if_set:nnT {#1} {#2-indefinite} 321 | { \c_space_tl } 322 | } 323 | 324 | % #1: text 325 | \cs_new:Npn \__acro_pdfstring_upper:n #1 326 | { \text_titlecase_first:e {#1} } 327 | 328 | \cs_generate_variant:Nn \text_titlecase_first:n {e} 329 | 330 | % -------------------------------------------------------------------------- 331 | % long-short 332 | \acro_pdfstring_template_new:nn {long-short} 333 | { 334 | \acro_property_get:nn {#1} {long} 335 | \acro_space: 336 | ( \acro_property_get:nn {#1} {pdfstring} ) 337 | } 338 | 339 | % indef-long-short 340 | \acro_pdfstring_template_new:nn {indef-long-short} 341 | { 342 | \__acro_pdfstring_indefinite:nn {#1} {long} 343 | \acro_property_get:nn {#1} {long} 344 | \acro_space: 345 | ( \acro_property_get:nn {#1} {pdfstring} ) 346 | } 347 | 348 | % Long-short 349 | \acro_pdfstring_template_new:nn {Long-short} 350 | { 351 | \__acro_pdfstring_upper:n 352 | { \acro_property_get:nn {#1} {long} } 353 | \acro_space: 354 | ( \acro_property_get:nn {#1} {pdfstring} ) 355 | } 356 | 357 | % Indef-long-short 358 | \acro_pdfstring_template_new:nn {Indef-long-short} 359 | { 360 | \__acro_pdfstring_upper:n 361 | { 362 | \__acro_pdfstring_indefinite:nn {#1} {long} 363 | \acro_property_get:nn {#1} {long} 364 | } 365 | \acro_space: 366 | ( \acro_property_get:nn {#1} {pdfstring} ) 367 | } 368 | 369 | % long-short-plural 370 | \acro_pdfstring_template_new:nn {long-short-plural} 371 | { 372 | \__acro_pdfstring_plural:nn {#1} {long} 373 | \acro_space: 374 | ( \__acro_pdfstring_plural:nn {#1} {short} ) 375 | } 376 | 377 | % Long-short-plural 378 | \acro_pdfstring_template_new:nn {Long-short-plural} 379 | { 380 | \__acro_pdfstring_upper:n 381 | { \__acro_pdfstring_plural:nn {#1} {long} } 382 | \acro_space: 383 | ( \__acro_pdfstring_plural:nn {#1} {short} ) 384 | } 385 | 386 | % -------------------------------------------------------------------------- 387 | % short-long 388 | \acro_pdfstring_template_new:nn {short-long} 389 | { 390 | \acro_property_get:nn {#1} {pdfstring} 391 | \acro_space: 392 | ( \acro_property_get:nn {#1} {long} ) 393 | } 394 | 395 | % indef-short-long 396 | \acro_pdfstring_template_new:nn {indef-short-long} 397 | { 398 | \__acro_pdfstring_indefinite:nn {#1} {short} 399 | \acro_property_get:nn {#1} {pdfstring} 400 | \acro_space: 401 | ( \acro_property_get:nn {#1} {long} ) 402 | } 403 | 404 | % Short-long 405 | \acro_pdfstring_template_new:nn {Short-long} 406 | { 407 | \__acro_pdfstring_upper:n 408 | { \acro_property_get:nn {#1} {pdfstring} } 409 | \acro_space: 410 | ( \acro_property_get:nn {#1} {long} ) 411 | } 412 | 413 | % Indef-short-long 414 | \acro_pdfstring_template_new:nn {Indef-short-long} 415 | { 416 | \__acro_pdfstring_upper:n 417 | { 418 | \__acro_pdfstring_indefinite:nn {#1} {short} 419 | \acro_property_get:nn {#1} {pdfstring} 420 | } 421 | \acro_space: 422 | ( \acro_property_get:nn {#1} {long} ) 423 | } 424 | 425 | % short-long-plural 426 | \acro_pdfstring_template_new:nn {short-long-plural} 427 | { 428 | \__acro_pdfstring_plural:nn {#1} {short} 429 | \acro_space: 430 | ( \__acro_pdfstring_plural:nn {#1} {long} ) 431 | } 432 | 433 | % Short-long-plural 434 | \acro_pdfstring_template_new:nn {Short-long-plural} 435 | { 436 | \__acro_pdfstring_upper:n 437 | { \__acro_pdfstring_plural:nn {#1} {short} } 438 | \acro_space: 439 | ( \__acro_pdfstring_plural:nn {#1} {long} ) 440 | } 441 | 442 | % -------------------------------------------------------------------------- 443 | % short 444 | \acro_pdfstring_template_new:nn {short} 445 | { \acro_property_get:nn {#1} {pdfstring} } 446 | 447 | % indef-short 448 | \acro_pdfstring_template_new:nn {indef-short} 449 | { 450 | \__acro_pdfstring_indefinite:nn {#1} {short} 451 | \acro_property_get:nn {#1} {pdfstring} 452 | } 453 | 454 | % Short 455 | \acro_pdfstring_template_new:nn {Short} 456 | { 457 | \__acro_pdfstring_upper:n 458 | { \acro_property_get:nn {#1} {pdfstring} } 459 | } 460 | 461 | % Indef-short 462 | \acro_pdfstring_template_new:nn {Indef-short} 463 | { 464 | \__acro_pdfstring_upper:n 465 | { 466 | \__acro_pdfstring_indefinite:nn {#1} {short} 467 | \acro_property_get:nn {#1} {pdfstring} 468 | } 469 | } 470 | 471 | % short-plural 472 | \acro_pdfstring_template_new:nn {short-plural} 473 | { \__acro_pdfstring_plural:nn {#1} {short} } 474 | 475 | % Short-plural 476 | \acro_pdfstring_template_new:nn {Short-plural} 477 | { 478 | \__acro_pdfstring_upper:n 479 | { \__acro_pdfstring_plural:nn {#1} {short} } 480 | } 481 | 482 | % -------------------------------------------------------------------------- 483 | % alt 484 | \acro_pdfstring_template_new:nn {alt} 485 | { 486 | \acro_property_get_if_set:nnF {#1} {alt} 487 | { \acro_pdfstring_template:nn {#1} {short} } 488 | } 489 | 490 | % indef-alt 491 | \acro_pdfstring_template_new:nn {indef-alt} 492 | { 493 | \acro_property_if_set:nnTF {#1} {alt} 494 | { 495 | \__acro_pdfstring_indefinite:nn {#1} {alt} 496 | \acro_property_get:nn {#1} {alt} 497 | } 498 | { \acro_pdfstring_template:nn {#1} {indef-short} } 499 | } 500 | 501 | % Alt 502 | \acro_pdfstring_template_new:nn {Alt} 503 | { 504 | \acro_property_if_set:nnTF {#1} {alt} 505 | { 506 | \__acro_pdfstring_upper:n 507 | { \acro_property_get:nn {#1} {alt} } 508 | } 509 | { \acro_pdfstring_template:nn {#1} {Short} } 510 | } 511 | 512 | % Indef-alt 513 | \acro_pdfstring_template_new:nn {Indef-alt} 514 | { 515 | \acro_property_if_set:nnTF {#1} {alt} 516 | { 517 | \__acro_pdfstring_upper:n 518 | { \__acro_pdfstring_indefinite:nn {#1} {alt} } 519 | \acro_property_get:nn {#1} {alt} 520 | } 521 | { \acro_pdfstring_template:nn {#1} {Indef-short} } 522 | } 523 | 524 | % alt-plural 525 | \acro_pdfstring_template_new:nn {alt-plural} 526 | { 527 | \acro_property_if_set:nnTF {#1} {alt} 528 | { \__acro_pdfstring_plural:nn {#1} {alt} } 529 | { \acro_pdfstring_template:nn {#1} {short-plural} } 530 | } 531 | 532 | % Alt-plural 533 | \acro_pdfstring_template_new:nn {Alt-plural} 534 | { 535 | \acro_property_if_set:nnTF {#1} {alt} 536 | { 537 | \__acro_pdfstring_upper:n 538 | { \__acro_pdfstring_plural:nn {#1} {alt} } 539 | } 540 | { \acro_pdfstring_template:nn {#1} {Short-plural} } 541 | } 542 | 543 | % -------------------------------------------------------------------------- 544 | % long 545 | \acro_pdfstring_template_new:nn {long} 546 | { \acro_property_get:nn {#1} {long} } 547 | 548 | % indef-long 549 | \acro_pdfstring_template_new:nn {indef-long} 550 | { 551 | \__acro_pdfstring_indefinite:nn {#1} {long} 552 | \acro_property_get:nn {#1} {long} 553 | } 554 | 555 | % Long 556 | \acro_pdfstring_template_new:nn {Long} 557 | { 558 | \__acro_pdfstring_upper:n 559 | { \acro_property_get:nn {#1} {long} } 560 | } 561 | 562 | % Indef-long 563 | \acro_pdfstring_template_new:nn {Indef-long} 564 | { 565 | \__acro_pdfstring_upper:n 566 | { 567 | \__acro_pdfstring_indefinite:nn {#1} {long} 568 | \acro_property_get:nn {#1} {long} 569 | } 570 | } 571 | 572 | % long-plural 573 | \acro_pdfstring_template_new:nn {long-plural} 574 | { \__acro_pdfstring_plural:nn {#1} {long} } 575 | 576 | % Long-plural 577 | \acro_pdfstring_template_new:nn {Long-plural} 578 | { 579 | \__acro_pdfstring_upper:n 580 | { \__acro_pdfstring_plural:nn {#1} {long} } 581 | } 582 | 583 | % -------------------------------------------------------------------------- 584 | % first 585 | \acro_pdfstring_template_let:nn {first} {short} 586 | 587 | % indef-first 588 | \acro_pdfstring_template_let:nn {indef-first} {indef-short} 589 | 590 | % First 591 | \acro_pdfstring_template_let:nn {First} {Short} 592 | 593 | % indef-first 594 | \acro_pdfstring_template_let:nn {Indef-first} {Indef-short} 595 | 596 | % first-plural 597 | \acro_pdfstring_template_let:nn {first-plural} {short-plural} 598 | 599 | % First-plural 600 | \acro_pdfstring_template_let:nn {First-plural} {Short-plural} 601 | 602 | % -------------------------------------------------------------------------- 603 | 604 | \acro_at_begin_document:n 605 | { 606 | \acro_package_if_loaded:nT {hyperref} 607 | { 608 | \pdfstringdefDisableCommands 609 | { 610 | \acro_set_pdf_cs:Nn \ac {first} 611 | \acro_set_pdf_cs:Nn \iac {indef-first} 612 | \acro_set_pdf_cs:Nn \Ac {First} 613 | \acro_set_pdf_cs:Nn \Iac {Indef-first} 614 | \acro_set_pdf_cs:Nn \acs {short} 615 | \acro_set_pdf_cs:Nn \iacs {indef-short} 616 | \acro_set_pdf_cs:Nn \Acs {Short} 617 | \acro_set_pdf_cs:Nn \Iacs {Indef-short} 618 | \acro_set_pdf_cs:Nn \acl {long} 619 | \acro_set_pdf_cs:Nn \iacl {indef-long} 620 | \acro_set_pdf_cs:Nn \Acl {Long} 621 | \acro_set_pdf_cs:Nn \Iacl {Indef-long} 622 | \acro_set_pdf_cs:Nn \aca {alt} 623 | \acro_set_pdf_cs:Nn \iaca {indef-alt} 624 | \acro_set_pdf_cs:Nn \Aca {Alt} 625 | \acro_set_pdf_cs:Nn \Iaca {Indef-alt} 626 | 627 | \acro_set_pdf_cs:Nn \acp {first-plural} 628 | \acro_set_pdf_cs:Nn \Acp {First-plural} 629 | \acro_set_pdf_cs:Nn \acsp {short-plural} 630 | \acro_set_pdf_cs:Nn \Acsp {Short-plural} 631 | \acro_set_pdf_cs:Nn \aclp {long-plural} 632 | \acro_set_pdf_cs:Nn \Aclp {Long-plural} 633 | \acro_set_pdf_cs:Nn \acap {alt-plural} 634 | \acro_set_pdf_cs:Nn \Acap {Alt-plural} 635 | \cs_set_eq:NN \acro_format:nnn \use_iii:nnn 636 | \cs_set:Npn \@ {} 637 | } 638 | \cs_set_protected:Npn \acro_hyper_page:n #1 { \hyperpage {#1} } 639 | } {} 640 | } 641 | 642 | % ---------------------------------------------------------------------------- 643 | \AcroModuleEnd 644 | -------------------------------------------------------------------------------- /code/acro.ppfixes.code.tex: -------------------------------------------------------------------------------- 1 | \AcroModule{ppfixes}{pre- and postfixes to acronyms} 2 | % -------------------------------------------------------------------------- 3 | % articles 4 | \bool_new:N \l__acro_article_bool 5 | \tl_new:N \g__acro_articles_tl 6 | 7 | % #1: name 8 | % #2: default 9 | \cs_new_protected:Npn \acro_article_declare:nn #1#2 10 | { 11 | \tl_gput_right:Nn \g__acro_articles_tl {{#1}} 12 | \acro_property_declare:nn {} {#1} 13 | \acro_list_map:nn {short} 14 | { 15 | \DeclareAcroPropertyAlias {##1-#1} {#1} 16 | \str_if_in:nnF {##1} {-acc} 17 | { \DeclareAcroPropertyAlias {##1-acc-#1} {##1-#1} } 18 | } 19 | \acro_list_map:nn {long} 20 | { 21 | \DeclareAcroPropertyAlias {##1-#1} {#1} 22 | \str_if_in:nnF {##1} {acc} 23 | { \DeclareAcroPropertyAlias {##1-acc-#1} {##1-#1} } 24 | } 25 | \bool_new:c {l__acro_article_#1_bool} 26 | \tl_new:c {l__acro_article_#1_tl} 27 | \exp_args:Nc \NewDocumentCommand {acro#1} {} { \use:c {acro_#1:} } 28 | \cs_new_protected:cpn {acro_#1:} 29 | { 30 | \bool_if:NF \l__acro_article_bool 31 | { 32 | \bool_set_true:c {l__acro_article_#1_bool} 33 | \bool_set_true:N \l__acro_article_bool 34 | } 35 | } 36 | \keys_define:nn {acro} 37 | { 38 | #1 .tl_set:c = {l__acro_article_#1_tl} , 39 | #1 .initial:n = #2 40 | } 41 | } 42 | 43 | % #1: id 44 | \cs_new_protected:Npn \__acro_set_article_defaults:n #1 45 | { 46 | \tl_map_tokens:Nn \g__acro_articles_tl 47 | { \__acro_default_article:nn {#1} } 48 | } 49 | 50 | % #1: id 51 | % #2: article 52 | \cs_new_protected:Npn \__acro_default_article:nn #1#2 53 | { \acro_property_set:nnv {#1} {#2} {l__acro_article_#2_tl} } 54 | 55 | % -------------------------------------------------------------------------- 56 | % mechanism for endings: 57 | \tl_new:N \l__acro_endings_tl 58 | 59 | \bool_new:N \l__acro_ending_bool 60 | 61 | \acro_attribute_new:n {short:endings} 62 | \acro_attribute_new:n {long:endings} 63 | 64 | \cs_new_protected:Npn \__acro_declare_ending_properties:n #1 65 | { 66 | \acro_property_declare:nn {} {#1} 67 | \acro_property_declare:nn {} {#1-form} 68 | } 69 | 70 | % #1: ending 71 | % #2: short default 72 | % #3: long default 73 | \cs_new_protected:Npn \acro_declare_ending:nnn #1#2#3 74 | { 75 | \bool_new:c {l__acro_ending_#1_bool} 76 | \exp_args:Nc \NewDocumentCommand {acro#1} {} { \use:c {acro_#1:} } 77 | \cs_new_protected:cpn {acro_#1:} 78 | { 79 | \bool_if:NF \l__acro_ending_bool 80 | { 81 | \bool_set_true:c {l__acro_ending_#1_bool} 82 | \bool_set_true:N \l__acro_ending_bool 83 | } 84 | } 85 | \prg_new_conditional:cpnn {acro_if_#1:} {p,T,F,TF} 86 | { 87 | \bool_if:cTF {l__acro_ending_#1_bool} 88 | { \prg_return_true: } 89 | { \prg_return_false: } 90 | } 91 | \tl_put_right:Nn \l__acro_endings_tl {{#1}} 92 | \keys_define:nn {acro} 93 | { 94 | short-#1-ending .code:n = 95 | \acro_attribute_set:nnn {short:endings} {#1} {##1} , 96 | short-#1-ending .initial:n = #2 , 97 | long-#1-ending .code:n = 98 | \acro_attribute_set:nnn {long:endings} {#1} {##1} , 99 | long-#1-ending .initial:n = #3 100 | } 101 | \__acro_declare_ending_properties:n {#1}% plural + plural-form 102 | \acro_list_map:nn {short} 103 | { 104 | % short-plural + short-plural-form 105 | \__acro_declare_ending_properties:n {##1-#1} 106 | % short-plural = plural 107 | \acro_property_make_alias:nn {##1-#1} {#1} 108 | } 109 | \acro_list_map:nn {long} 110 | { 111 | % long-plural + long-plural-form 112 | \__acro_declare_ending_properties:n {##1-#1} 113 | % long-plural = plural 114 | \acro_property_make_alias:nn {##1-#1} {#1} 115 | % long-plural-form = plural-form 116 | \acro_property_make_alias:nn {##1-#1-form} {#1-form} 117 | } 118 | } 119 | 120 | \cs_new_protected:Npn \acro_disable_endings: 121 | { 122 | \tl_map_tokens:Nn \l__acro_endings_tl 123 | { \__acro_disable_ending:n } 124 | } 125 | 126 | \cs_new_protected:Npn \__acro_disable_ending:n #1 127 | { \bool_set_false:c {l__acro_ending_#1_bool} } 128 | 129 | % #1: id 130 | % #2: short|long 131 | \cs_new_protected:Npn \__acro_set_endings:nn #1#2 132 | { 133 | \acro_list_map:nn {#2} 134 | { 135 | \tl_map_inline:Nn \l__acro_endings_tl 136 | { \__acro_set_ending:nnnn {#1} {#2} {##1} {####1} } 137 | } 138 | } 139 | 140 | % #1: id 141 | % #2: short|long 142 | % #3: property 143 | % #4: ending 144 | \cs_new_protected:Npn \__acro_set_ending:nnnn #1#2#3#4 145 | { 146 | \acro_property_if_set:nnF {#1} {#3-#4-form} 147 | { 148 | \acro_property_if_set:nnF {#1} {#3-#4} 149 | { 150 | \__acro_property_set:nne {#1} {#3-#4} 151 | { \acro_attribute_get:nn {#2:endings} {#4} } 152 | } 153 | } 154 | } 155 | 156 | % #1: id 157 | \cs_new_protected:Npn \acro_set_endings:n #1 158 | { 159 | \__acro_set_endings:nn {#1} {short} 160 | \__acro_set_endings:nn {#1} {long} 161 | } 162 | 163 | % #1: ending 164 | \cs_new_protected:Npn \acro_unset_ending:n #1 165 | { \bool_set_false:c {l__acro_ending_#1_bool} } 166 | 167 | \cs_new_protected:Npn \acro_reset_endings: 168 | { 169 | \tl_map_tokens:Nn \l__acro_endings_tl { \acro_unset_ending:n } 170 | \bool_set_false:N \l__acro_ending_bool 171 | } 172 | 173 | % ---------------------------------------------------------------------------- 174 | \AcroModuleEnd 175 | -------------------------------------------------------------------------------- /code/acro.start.code.tex: -------------------------------------------------------------------------------- 1 | % -------------------------------------------------------------------------- 2 | % the ACRO package 3 | % 4 | % Typeset Acronyms 5 | % 6 | % -------------------------------------------------------------------------- 7 | % Clemens Niederberger 8 | % Web: https://github.com/cgnieder/acro/ 9 | % E-Mail: contact@mychemistry.eu 10 | % -------------------------------------------------------------------------- 11 | % Copyright 2011--2022 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.3c 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.3c or later is part of all distributions of LaTeX 19 | % version 2008/05/04 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 | \DeclareRelease{v2}{2020-03-07}{acro2.sty} 26 | \DeclareRelease{version2}{2020-03-07}{acro2.sty} 27 | 28 | \RequirePackage {l3keys2e} 29 | \ExplSyntaxOn 30 | 31 | % setup package: 32 | \tl_const:Nn \c_acro_package_name_tl {acro} 33 | \tl_const:Nn \c_acro_date_tl {2022/04/01} 34 | \tl_const:Nn \c_acro_version_major_number_tl {3} 35 | \tl_const:Nn \c_acro_version_minor_number_tl {8} 36 | \tl_const:Nn \c_acro_version_subrelease_tl {} 37 | \tl_const:Nx \c_acro_version_number_tl 38 | { 39 | \c_acro_version_major_number_tl . 40 | \c_acro_version_minor_number_tl 41 | } 42 | \tl_const:Nx \c_acro_version_tl 43 | { 44 | \c_acro_version_number_tl 45 | \c_acro_version_subrelease_tl 46 | } 47 | \tl_const:Nn \c_acro_info_tl {typeset~ acronyms~ and~ other~ abbreviations} 48 | 49 | \ProvidesExplPackage 50 | {\c_acro_package_name_tl} 51 | {\c_acro_date_tl} 52 | {\c_acro_version_tl} 53 | {\c_acro_info_tl \c_space_tl (CN)} 54 | \DeclareCurrentRelease{v3}{\c_acro_date_tl} 55 | 56 | % -------------------------------------------------------------------------- 57 | % document hooks: 58 | \tl_new:N \g_acro_end_document_hook_tl 59 | \tl_new:N \g_acro_begin_document_hook_tl 60 | 61 | \hook_gput_code:nnn {begindocument} {acro} { \tl_use:N \g_acro_begin_document_hook_tl } 62 | \hook_gput_code:nnn {enddocument} {acro} { \tl_use:N \g_acro_end_document_hook_tl } 63 | 64 | \cs_new_protected:Npn \acro_at_begin_document:n #1 65 | { \tl_gput_right:Nn \g_acro_begin_document_hook_tl {#1} } 66 | 67 | \cs_new_protected:Npn \acro_at_end_document:n #1 68 | { \tl_gput_right:Nn \g_acro_end_document_hook_tl {#1} } 69 | 70 | % -------------------------------------------------------------------------- 71 | % load-time messages: 72 | \msg_new:nnn {acro} {load-time-option} 73 | { 74 | `#1'~ is~ a~ load-time~ option! \\ 75 | You~ cannot~ set~ it~ with~ \token_to_str:N \acsetup ! \\ 76 | You~ need~ to~ use~ \token_to_str:N \usepackage [#1] {acro} . 77 | } 78 | 79 | \msg_new:nnn {acro} {unknown-option} 80 | { 81 | Unknown~ option~ `#1' \\ 82 | I~ don't~ know~ the~ option~ `#1'.~ Please~ make~ sure~ there~ is~ no~ 83 | typo.~ Check~ the~ manual~ for~ help. 84 | } 85 | 86 | \msg_new:nnn {acro} {version} 87 | { 88 | Please~ specify~ the~ version~ by~ saying~ \token_to_str:N 89 | \usepackage{acro}[=v#1],~ i.e., using~ LaTeX's~ release~ mechanism. 90 | } 91 | 92 | % -------------------------------------------------------------------------- 93 | % re-compile mechanism: 94 | \bool_new:N \g__acro_rerun_bool 95 | \tl_new:N \g__acro_rerun_message_tl 96 | 97 | \tl_const:Nn \c__acro_rerun_general_tl 98 | { Rerun~ to~ get~ `acro'~ synchronized. } 99 | 100 | \tl_const:Nn \c__acro_rerun_property_tl 101 | { 102 | Acronym~ properties~ may~ have~ changed.~ Rerun~ to~ get~ them~ 103 | synchronized. 104 | } 105 | 106 | \tl_const:Nn \c__acro_rerun_list_tl 107 | { 108 | Empty~ acronym~ list.~ If~ you~ have~ used~ acronyms~ then~ re-compile~ 109 | to~ get~ the~ list~ filled.~ Otherwise~ remove~ \token_to_str:N 110 | \printacronyms 111 | } 112 | 113 | \msg_new:nnn {acro} {rerun} { \use:c {c__acro_rerun_#1_tl} } 114 | 115 | \prg_new_conditional:Npnn \acro_if_rerun: {p,T,F,TF} 116 | { 117 | \bool_if:NTF \g__acro_rerun_bool 118 | { \prg_return_true: } 119 | { \prg_return_false: } 120 | } 121 | 122 | \cs_new_protected:Npn \acro_rerun:n #1 123 | { 124 | \bool_gset_true:N \g__acro_rerun_bool 125 | \tl_map_inline:Nn \g__acro_rerun_message_tl 126 | { 127 | \tl_if_eq:nnT {##1} {#1} 128 | { \tl_map_break:n { \use_none:nn } } 129 | } 130 | \use:n { \tl_gput_right:Nn \g__acro_rerun_message_tl {{#1}} } 131 | } 132 | 133 | \cs_new_protected:Npn \acro_do_rerun: 134 | { 135 | \acro_if_rerun:T 136 | { 137 | \tl_map_inline:Nn \g__acro_rerun_message_tl 138 | { 139 | \str_case:nnTF {##1} 140 | { 141 | {property} { \msg_warning:nnn {acro} {rerun} {property} } 142 | {list} { \msg_warning:nnn {acro} {rerun} {list} } 143 | {general} { \msg_warning:nnn {acro} {rerun} {general} } 144 | } 145 | { \tl_map_break: } 146 | { \msg_warning:nnn {acro} {rerun} {general} } 147 | } 148 | } 149 | } 150 | 151 | % -------------------------------------------------------------------------- 152 | % debugging mechanism: 153 | \bool_new:N \g__acro_debug_bool 154 | 155 | \prg_new_conditional:Npnn \acro_if_debug: {p,T,F,TF} 156 | { 157 | \bool_if:NTF \g__acro_debug_bool 158 | { \prg_return_true: } 159 | { \prg_return_false: } 160 | } 161 | 162 | % -------------------------------------------------------------------------- 163 | % check for stuff changed in the new version: 164 | \bool_new:N \g__acro_upgrade_bool 165 | 166 | \prg_new_conditional:Npnn \acro_if_upgrade: {p,T,F,TF} 167 | { 168 | \bool_if:NTF \g__acro_upgrade_bool 169 | { \prg_return_true: } 170 | { \prg_return_false: } 171 | } 172 | 173 | % -------------------------------------------------------------------------- 174 | % 175 | \bool_new:N \g__acro_final_bool 176 | 177 | \prg_new_conditional:Npnn \acro_if_final: {p,T,F,TF} 178 | { 179 | \bool_if:NTF \g__acro_final_bool 180 | { \prg_return_true: } 181 | { \prg_return_false: } 182 | } 183 | 184 | % -------------------------------------------------------------------------- 185 | % load-time options: 186 | % #1: message name 187 | \cs_new_protected:Npn \__acro_loadtime_error:n #1 188 | { \msg_error:nnV {acro} {#1} \l_keys_key_str } 189 | 190 | \cs_new_protected:Npn \__acro_loadtime_warning:n #1 191 | { \msg_warning:nnV {acro} {#1} \l_keys_key_str } 192 | 193 | \cs_generate_variant:Nn \msg_error:nnn {nnV} 194 | \cs_generate_variant:Nn \msg_warning:nnn {nnV} 195 | 196 | \keys_define:nn {acro/package} 197 | { 198 | debug .bool_gset:N = \g__acro_debug_bool , 199 | debug .initial:n = false , 200 | upgrade .bool_gset:N = \g__acro_upgrade_bool , 201 | upgrade .initial:n = false , 202 | final .bool_gset:N = \g__acro_final_bool , 203 | final .initial:n = false , 204 | version .choice: , 205 | version / 2 .code:n = \msg_error:nnn {acro} {version} {#1} \file_input_stop: , 206 | version / 3 .code:n = \msg_warning:nnn {acro} {version} {#1} , 207 | unknown .code:n = \__acro_loadtime_warning:n {unknown-option} 208 | } 209 | 210 | \ProcessKeysPackageOptions {acro/package} 211 | 212 | \keys_define:nn {acro/package} 213 | { 214 | debug .code:n = \__acro_loadtime_error:n {load-time-option} , 215 | upgrade .code:n = \__acro_loadtime_error:n {load-time-option} , 216 | final .code:n = \__acro_loadtime_error:n {load-time-option} 217 | } 218 | 219 | % ---------------------------------------------------------------------------- 220 | % temporary variables: 221 | \tl_new:N \l__acro_tmpa_tl 222 | \tl_new:N \l__acro_tmpb_tl 223 | \tl_new:N \l__acro_tmpc_tl 224 | 225 | \str_new:N \l__acro_tmpa_str 226 | \str_new:N \l__acro_tmpb_str 227 | \str_new:N \l__acro_tmpc_str 228 | 229 | \bool_new:N \l__acro_tmpa_bool 230 | \bool_new:N \l__acro_tmpb_bool 231 | \bool_new:N \l__acro_tmpc_bool 232 | 233 | \seq_new:N \l__acro_tmpa_seq 234 | \seq_new:N \l__acro_tmpb_seq 235 | \seq_new:N \l__acro_tmpc_seq 236 | 237 | \int_new:N \l__acro_tmpa_int 238 | \int_new:N \l__acro_tmpb_int 239 | \int_new:N \l__acro_tmpc_int 240 | \int_new:N \l__acro_tmpd_int 241 | 242 | \clist_new:N \l__acro_tmpa_clist 243 | \clist_new:N \l__acro_tmpb_clist 244 | \clist_new:N \l__acro_tmpc_clist 245 | 246 | % ---------------------------------------------------------------------------- 247 | % module mechanism: 248 | \msg_new:nnn {acro} {module-missing} 249 | { 250 | You've~ requested~ the~ acro~ module~ `#1'~ but~ it~ appears~ to~ 251 | be~ missing~ on~ your~ system.~ Maybe~ you've~ misspelled~ the~ name?~ 252 | Loading~ the~ module~ will~ abort~ \msg_line_context: 253 | } 254 | 255 | \msg_new:nnn {acro} {loading-module} 256 | { Loading~ module~ `#1'~ ... } 257 | 258 | \msg_new:nnn {acro} {wrong-module-name} 259 | { The~ module~ file~ name~ is~ `#2'~ but~ it~ provides~ module~ `#1'. } 260 | 261 | \msg_new:nnn {acro} {forbidden-module} 262 | { 263 | You've~ requested~ the~ acro~ module~ `modules'~ \msg_line_context: .~ 264 | This~ module~ is~ a~ pseudo~ module~ which~ may~ not~ be~ loaded~ through~ 265 | the~ module~ loading~ mechansim. 266 | } 267 | 268 | % ---------------------------------------------------------------------------- 269 | \cs_generate_variant:Nn \str_if_eq:nnF {xx} 270 | \cs_generate_variant:Nn \msg_error:nnnn {nnnx} 271 | 272 | \prg_new_conditional:Npnn \acro_package_if_loaded:n #1 {p,T,F,TF} 273 | { 274 | \cs_if_exist:cTF {ver@#1.sty} 275 | { \prg_return_true: } 276 | { \prg_return_false: } 277 | } 278 | 279 | % ---------------------------------------------------------------------------- 280 | % this is for external file modules called "styles": 281 | \tl_const:Nn \c__acro_module_extension_tl {code.tex} 282 | \tl_const:Nn \c__acro_module_prefix_tl {acro} 283 | 284 | \tl_new:N \g__acro_modules_loaded_tl 285 | 286 | \cs_new_protected:Npn \acro_modules_load:n #1 287 | { \clist_map_inline:nn {#1} { \acro_module_load:n {##1} } } 288 | 289 | \cs_new_protected:Npn \acro_module_load:n #1 290 | { 291 | \tl_set:Nx \l_tmpa_tl { \tl_trim_spaces:n {#1} } 292 | \str_if_eq:VnTF \l_tmpa_tl {modules} 293 | { \msg_error:nn {acro} {forbidden-module} } 294 | { \__acro_module_load:V \l_tmpa_tl } 295 | } 296 | 297 | \cs_new_protected:Npn \__acro_module_load:n #1 298 | { 299 | \acro_module_if_loaded:nF {#1} 300 | { 301 | \acro_module_if_exist:nTF {#1} 302 | { 303 | \__acro_module_hook_use:nn {#1} {before} 304 | \msg_info:nnn {acro} {loading-module} {#1} 305 | \@onefilewithoptions 306 | {\c__acro_module_prefix_tl.#1}[][] 307 | \c__acro_module_extension_tl 308 | \__acro_module_hook_use:nn {#1} {after} 309 | } 310 | { \msg_error:nnn {acro} {module-missing} {#1} } 311 | } 312 | } 313 | \cs_generate_variant:Nn \__acro_module_load:n {V} 314 | 315 | \prg_new_conditional:Npnn \acro_module_if_loaded:n #1 {p,T,F,TF} 316 | { 317 | \tl_if_in:NnTF \g__acro_modules_loaded_tl {#1} 318 | { \prg_return_true: } 319 | { \prg_return_false: } 320 | } 321 | 322 | \prg_new_conditional:Npnn \acro_module_if_exist:n #1 {p,T,F,TF} 323 | { 324 | \file_if_exist:nTF 325 | {\c__acro_module_prefix_tl.#1.\c__acro_module_extension_tl} 326 | { \prg_return_true: } 327 | { \prg_return_false: } 328 | } 329 | 330 | % -------------------------------------------------------------------------- 331 | % module hooks: 332 | % #1: module 333 | % #2: code 334 | \cs_new_protected:Npn \acro_module_after:nn #1#2 335 | { 336 | \acro_module_if_loaded:nTF {#1} 337 | {#2} 338 | { \__acro_add_to_module_hook:nnn {#1} {after} {#2} } 339 | } 340 | 341 | % #1: module 342 | % #2: code 343 | \cs_new_protected:Npn \acro_module_before:nn #1#2 344 | { 345 | % TODO: error in T case? 346 | \acro_module_if_loaded:nF {#1} 347 | { \__acro_add_to_module_hook:nnn {#1} {before} {#2} } 348 | } 349 | 350 | % #1: module 351 | % #2: hook name 352 | % #3: code 353 | \cs_new_protected:Npn \__acro_add_to_module_hook:nnn #1#2#3 354 | { 355 | \acro_module_if_loaded:nF {#1} 356 | { 357 | \tl_if_exist:cF {g__acro_module_hook_#1_#2_tl} 358 | { \tl_new:c {g__acro_module_hook_#1_#2_tl} } 359 | \tl_gput_right:cn {g__acro_module_hook_#1_#2_tl} {#3} 360 | } 361 | } 362 | 363 | % #1: module 364 | % #2: hook name 365 | \cs_new_protected:Npn \__acro_module_hook_use:nn #1#2 366 | { 367 | \tl_if_exist:cT {g__acro_module_hook_#1_#2_tl} 368 | { 369 | \tl_use:c {g__acro_module_hook_#1_#2_tl} 370 | \tl_gclear:c {g__acro_module_hook_#1_#2_tl} 371 | } 372 | } 373 | \cs_generate_variant:Nn \__acro_module_hook_use:nn {V} 374 | 375 | % -------------------------------------------------------------------------- 376 | \tl_new:N \l__acro_module_date_tl 377 | \tl_new:N \l__acro_module_version_tl 378 | 379 | \tl_set_eq:NN \l__acro_module_date_tl \c_acro_date_tl 380 | \tl_set_eq:NN \l__acro_module_version_tl \c_acro_version_tl 381 | 382 | \cs_new_protected:Npn \__acro_module:nn #1#2 383 | { 384 | \tl_gput_right:Nn \g__acro_modules_loaded_tl {{#1}} 385 | \str_if_eq:xxF 386 | {\c__acro_module_prefix_tl.#1.\c__acro_module_extension_tl} 387 | {\@currname.\@currext} 388 | { 389 | \msg_error:nnnxx {acro} {wrong-module-name} 390 | {#1} 391 | {\@currname.\@currext} 392 | } 393 | \ProvidesFile 394 | {\c__acro_module_prefix_tl.#1.\c__acro_module_extension_tl} 395 | [ 396 | \l__acro_module_date_tl 397 | \c_space_tl 398 | v \l__acro_module_version_tl 399 | \c_space_tl 400 | acro~ style~ file~ `#1'~ (#2) 401 | ] 402 | } 403 | 404 | % -------------------------------------------------------------------------- 405 | % define internal acro modules: 406 | \tl_new:N \g_acro_module_tl 407 | \tl_new:N \g__acro_module_stop_tl 408 | 409 | \cs_new_protected:Npn \acro_stop_module:n #1 410 | { \tl_gput_right:Nn \g__acro_module_stop_tl {{#1}} } 411 | 412 | % #1: name 413 | % #2: description 414 | \cs_new_protected:Npn \AcroModule #1#2 415 | { 416 | \msg_log:nnnn {acro} {loading-module} {#1} {#2} 417 | \tl_gput_right:Nn \g__acro_modules_loaded_tl {{#1}} 418 | \tl_gset:Nn \g_acro_module_tl {#1} 419 | \__acro_module_hook_use:nn {#1} {before} 420 | \tl_map_inline:Nn \g__acro_module_stop_tl 421 | { 422 | \str_if_eq:nnT {##1} {#1} 423 | { \tl_map_break:n { \__acro_gobble_module:w } } 424 | } 425 | } 426 | 427 | \cs_new_protected:Npn \AcroModuleEnd 428 | { \__acro_module_hook_use:Vn \g_acro_module_tl {after} } 429 | 430 | \cs_new_protected:Npn \__acro_gobble_module:w #1 \AcroModuleEnd {} 431 | 432 | \bool_lazy_or:nnT 433 | { \acro_if_final_p: } 434 | { !\acro_if_upgrade_p: } 435 | { \acro_stop_module:n {upgrade} } 436 | 437 | % -------------------------------------------------------------------------- 438 | % style files 439 | \NewDocumentCommand \AcroStyle {smO{}} 440 | { 441 | \__acro_module:nn {style.#2} {#3} 442 | \IfBooleanT {#1} { \ExplSyntaxOn } 443 | } 444 | 445 | \cs_new_protected:Npn \acro_style_load:n #1 446 | { \clist_map_inline:nn {#1} { \acro_module_load:n {style.##1} } } 447 | 448 | \keys_define:nn {acro} 449 | { load-style .code:n = \acro_style_load:n {#1} } 450 | 451 | % -------------------------------------------------------------------------- 452 | \acro_if_debug:TF 453 | { 454 | \cs_new_protected:Npn \__acro_debug_start:n #1 455 | { 456 | \iow_term:n {} 457 | \iow_term:n {#1} 458 | \acro_package_if_loaded:nT {l3benchmark} { \benchmark_tic: } 459 | } 460 | \cs_new_protected:Npn \__acro_debug_stop: 461 | { \acro_package_if_loaded:nT {l3benchmark} { \benchmark_toc: } } 462 | } 463 | { 464 | \cs_new_protected:Npn \__acro_debug_start:n #1 {} 465 | \cs_new_protected:Npn \__acro_debug_stop: {} 466 | } 467 | % -------------------------------------------------------------------------- 468 | -------------------------------------------------------------------------------- /code/acro.templates.code.tex: -------------------------------------------------------------------------------- 1 | \AcroModule{templates}{templates for typesetting exercises} 2 | 3 | \msg_new:nnn {acro} {template-exists} 4 | { 5 | The~ template~ `#1'~ (template~ type~ `#2')~ \msg_line_context: \ 6 | already~ is~ defined. 7 | } 8 | 9 | \msg_new:nnn {acro} {unknown-template} 10 | { 11 | The~ template~ `#1'~ (template~ type~ `#2')~ \msg_line_context: \ 12 | does~ not~ seem~ to~ be~ defined. 13 | } 14 | 15 | \msg_new:nnn {acro} {template-type-exists} 16 | { The~ template~ type~ `#1'~ already~ exists~ \msg_line_context: } 17 | 18 | \msg_new:nnn {acro} {package-needed} 19 | { 20 | The~ template~ `#1'~ needs~ the~ package~ `#2'~ loaded~ 21 | \msg_line_context: 22 | } 23 | 24 | % ---------------------------------------------------------------------------- 25 | \seq_new:N \l__acro_template_types_seq 26 | 27 | % #1: template type 28 | \cs_new_protected:Npn \acro_template_type_new:n #1 29 | { 30 | \seq_if_in:NnTF \l__acro_template_types_seq {#1} 31 | { \msg_error:nnn {acro} {template-type-exists} {#1} } 32 | { 33 | \seq_put_right:Nn \l__acro_template_types_seq {#1} 34 | \acro_attribute_new:n {template::#1} 35 | } 36 | } 37 | 38 | % #1: template type 39 | % #2: template name 40 | % #3: code 41 | \cs_new_protected:Npn \__acro_template_add:nnn #1#2#3 42 | { 43 | \acro_template_if_exist:nnTF {#1} {#2} 44 | { \msg_error:nnnn {acro} {template-exists} {#2} {#1} } 45 | { 46 | \tl_new:c {l__acro_template_#1_#2_setup_tl} 47 | \tl_new:c {l__acro_next_template_#1_#2_setup_tl} 48 | \acro_attribute_set:nnn {template::#1} {#2} {#3} 49 | } 50 | } 51 | 52 | % #1: template type 53 | % #2: template name 54 | % #3: code 55 | \cs_new_protected:Npn \__acro_template_change:nnn #1#2#3 56 | { 57 | \acro_template_if_exist:nnTF {#1} {#2} 58 | { \acro_attribute_set:nnn {template::#1} {#2} {#3} } 59 | { \msg_error:nnnn {acro} {unknown-template} {#2} {#1} } 60 | } 61 | 62 | % #1: template type 63 | % #2: template name 64 | \prg_new_conditional:Npnn \acro_template_if_exist:nn #1#2 {T,F,TF} 65 | { 66 | \acro_attribute_if_set:nnTF {template::#1} {#2} 67 | { \prg_return_true: } 68 | { \prg_return_false: } 69 | } 70 | 71 | % #1: parameter number 72 | % #2: template type 73 | % #3: template name 74 | \cs_new_protected:Npn \__acro_template_get:nnn #1#2#3 75 | { 76 | \use:x 77 | { 78 | \cs_set:cn { __acro_tmp: \prg_replicate:nn {#1} {n} } 79 | { \acro_attribute_get:nn {template::#2} {#3} } 80 | } 81 | \use:c { __acro_tmp: \prg_replicate:nn {#1} {n} } 82 | } 83 | 84 | % using templates: 85 | % setup up the next usage of `template name': 86 | % #1: template type 87 | % #2: template name 88 | % #3: setup code 89 | \cs_new_protected:Npn \acro_template_setup:nnn #1#2#3 90 | { \tl_set:cn {l__acro_template_#1_#2_setup_tl} {#3} } 91 | 92 | \cs_new_protected:Npn \acro_next template_setup:nnn #1#2#3 93 | { \tl_set:cn {l__acro_next_template_#1_#2_setup_tl} {#3} } 94 | 95 | % #1: template type 96 | % #2: template name 97 | \cs_new_protected:Npn \__acro_template_do_setup:nn #1#2 98 | { 99 | \tl_use:c {l__acro_template_#1_#2_setup_tl} 100 | \tl_use:c {l__acro_next_template_#1_#2_setup_tl} 101 | } 102 | 103 | % #1: template type 104 | % #2: template name 105 | \cs_new_protected:Npn \__acro_clear_template_setup:nn #1#2 106 | { \tl_clear:c {l__acro_next_template_#1_#2_setup_tl} } 107 | 108 | % #1: template type 109 | % #2: template name 110 | \cs_new_protected:Npn \__acro_template_start:nn #1#2 111 | { 112 | \group_begin: 113 | \__acro_template_do_setup:nn {#1} {#2} 114 | \tl_clear_new:N \AcroTemplateType 115 | \tl_set:Nn \AcroTemplateType {#1} 116 | \tl_clear_new:N \AcroTemplateName 117 | \tl_set:Nn \AcroTemplateName {#2} 118 | } 119 | 120 | % #1: template type 121 | % #2: template name 122 | \cs_new_protected:Npn \__acro_template_stop:nn #1#2 123 | { \group_end: \__acro_clear_template_setup:nn {#1} {#2} } 124 | 125 | % typesetting the first appearance of acronym: pseudo template `first' 126 | 127 | % #1: parameter number 128 | % #2: template type 129 | % #3: template name 130 | \cs_new_protected:Npn \acro_template_use:nnn #1#2#3 131 | { 132 | \bool_set_false:N \l__acro_tmpa_bool 133 | \bool_set_false:N \l__acro_tmpb_bool 134 | \bool_lazy_and:nnT 135 | { \l__acro_use_only_first_bool } 136 | { \l__acro_use_bool } 137 | { 138 | \bool_set_true:N \l__acro_tmpa_bool 139 | \bool_set_false:N \l__acro_use_bool 140 | } 141 | \str_case:nnF {#3} 142 | { 143 | {first} { 144 | \bool_if:NT \l__acro_tmpa_bool 145 | { \bool_set_true:N \l__acro_use_bool } 146 | \bool_lazy_and:nnTF 147 | { !\l__acro_first_bool } 148 | { \acro_if_single_p:V \l_acro_id_tl } 149 | { 150 | \acro_property_if_set:VnTF \l_acro_id_tl {single} 151 | { \bool_set_true:N \l__acro_tmpb_bool } 152 | { 153 | \acro_property_if_set:VnTF \l_acro_id_tl {single-style} 154 | { 155 | \tl_set:Ne \l__acro_tmpa_tl 156 | { \acro_property_get:Vn \l_acro_id_tl {single-style} } 157 | } 158 | { \tl_set_eq:NN \l__acro_tmpa_tl \l__acro_single_tl } 159 | } 160 | } 161 | { 162 | \acro_if_first:VTF \l_acro_id_tl 163 | { 164 | \acro_property_if_set:VnTF \l_acro_id_tl {first-style} 165 | { 166 | \tl_set:Ne \l__acro_tmpa_tl 167 | { \acro_property_get:Vn \l_acro_id_tl {first-style} } 168 | } 169 | { \tl_set_eq:NN \l__acro_tmpa_tl \l__acro_first_style_tl } 170 | } 171 | { 172 | \acro_property_if_set:VnTF \l_acro_id_tl {subsequent-style} 173 | { 174 | \tl_set:Ne \l__acro_tmpa_tl 175 | { \acro_property_get:Vn \l_acro_id_tl {subsequent-style} } 176 | } 177 | { \tl_set_eq:NN \l__acro_tmpa_tl \l__acro_subsequent_tl } 178 | } 179 | } 180 | } 181 | {single} { 182 | \acro_property_if_set:VnTF \l_acro_id_tl {single} 183 | { \bool_set_true:N \l__acro_tmpb_bool } 184 | { 185 | \acro_property_if_set:VnTF \l_acro_id_tl {single-style} 186 | { 187 | \tl_set:Ne \l__acro_tmpa_tl 188 | { \acro_property_get:Vn \l_acro_id_tl {single-style} } 189 | } 190 | { \tl_set_eq:NN \l__acro_tmpa_tl \l__acro_single_tl } 191 | } 192 | } 193 | } 194 | { \tl_set:Nn \l__acro_tmpa_tl {#3} } 195 | \str_if_eq:VnT \l__acro_tmpa_tl {first} 196 | { 197 | \acro_property_if_set:VnTF \l_acro_id_tl {first-style} 198 | { 199 | \tl_set:Ne \l__acro_tmpa_tl 200 | { \acro_property_get:Vn \l_acro_id_tl {first-style} } 201 | } 202 | { \tl_set_eq:NN \l__acro_tmpa_tl \l__acro_first_style_tl } 203 | } 204 | \bool_if:NTF \l__acro_tmpb_bool 205 | { \__acro_template_use:nnn {#1} {#2} {single} } 206 | { \__acro_template_use:nnV {#1} {#2} \l__acro_tmpa_tl } 207 | } 208 | \cs_generate_variant:Nn \acro_template_use:nnn {nnV} 209 | 210 | \cs_new_protected:Npn \__acro_template_use:nnn #1#2#3 211 | { 212 | \acro_template_if_exist:nnTF {#2} {#3} 213 | { \__acro_template_get:nnn {#1} {#2} {#3} } 214 | { 215 | \msg_warning:nnnn {acro} {unknown-template} {#3} {#2} 216 | \__acro_template_get:nnn {#1} {#2} {first} 217 | } 218 | } 219 | \cs_generate_variant:Nn \__acro_template_use:nnn {nnx,nnV} 220 | 221 | % ---------------------------------------------------------------------------- 222 | % acronym templates: 223 | \acro_template_type_new:n {acronym} 224 | 225 | % #1: template name 226 | % #2: code 227 | \cs_new_protected:Npn \acro_acronym_template_new:nn #1#2 228 | { 229 | \__acro_template_add:nnn {acronym} {#1} 230 | { 231 | \__acro_template_start:nn {acronym} {#1} 232 | #2 233 | \__acro_template_stop:nn {acronym} {#1} 234 | } 235 | } 236 | 237 | % #1: template name 238 | % #2: code 239 | \cs_new_protected:Npn \acro_acronym_template_renew:nn #1#2 240 | { 241 | \__acro_template_change:nnn {acronym} {#1} 242 | { 243 | \__acro_template_start:nn {acronym} {#1} 244 | #2 245 | \__acro_template_stop:nn {acronym} {#1} 246 | } 247 | } 248 | 249 | % ---------------------------------------------------------------------------- 250 | % heading templates: 251 | \acro_template_type_new:n {heading} 252 | 253 | % #1: template name 254 | % #2: code 255 | \cs_new_protected:Npn \acro_heading_template_new:nn #1#2 256 | { 257 | \__acro_template_add:nnn {heading} {#1} 258 | { 259 | \__acro_template_start:nn {heading} {#1} 260 | #2 261 | \__acro_template_stop:nn {heading} {#1} 262 | } 263 | } 264 | 265 | % #1: template name 266 | % #2: code 267 | \cs_new_protected:Npn \acro_heading_template_renew:nn #1#2 268 | { 269 | \__acro_template_change:nnn {heading} {#1} 270 | { 271 | \__acro_template_start:nn {heading} {#1} 272 | #2 273 | \__acro_template_stop:nn {heading} {#1} 274 | } 275 | } 276 | 277 | % ---------------------------------------------------------------------------- 278 | % list templates: 279 | \acro_template_type_new:n {list} 280 | 281 | % #1: template name 282 | % #2: code 283 | \cs_new_protected:Npn \acro_list_template_new:nn #1#2 284 | { 285 | \__acro_template_add:nnn {list} {#1} 286 | { 287 | \tl_clear_new:N \AcronymTable 288 | \__acro_template_start:nn {list} {#1} 289 | #2 290 | \__acro_template_stop:nn {list} {#1} 291 | } 292 | } 293 | 294 | % #1: template name 295 | % #2: code 296 | \cs_new_protected:Npn \acro_list_template_renew:nn #1#2 297 | { 298 | \__acro_template_change:nnn {list} {#1} 299 | { 300 | \__acro_template_start:nn {list} {#1} 301 | \tl_clear_new:N \AcronymTable 302 | #2 303 | \__acro_template_stop:nn {list} {#1} 304 | } 305 | } 306 | 307 | % ---------------------------------------------------------------------------- 308 | \AcroModuleEnd 309 | -------------------------------------------------------------------------------- /code/acro.upgrade.code.tex: -------------------------------------------------------------------------------- 1 | \AcroModule{upgrade}{ease upgrading from version 2} 2 | 3 | % ---------------------------------------------------------------------------- 4 | \msg_new:nnn {acro} {deprecated} 5 | { 6 | On~ line~ \msg_line_number: : \\ 7 | The~ #1~ `#2'~ is~ deprecated.~ Use~ #1~ `#3'~ instead . 8 | } 9 | 10 | \msg_new:nnn {acro} {deprecated-function} 11 | { The~ command~ #1~ is~ deprecated.~ Use~ #2 instead . } 12 | 13 | \msg_new:nnn {acro} {removed-function} 14 | { The~ command~ #1~ has~ been~ removed. } 15 | 16 | \msg_new:nnn {acro} {removed} 17 | { 18 | On~ line~ \msg_line_number: : \\ 19 | The~ #1~ `#2'~ has~ been~ removed~ from~ acro. \\ 20 | If~ you~ need~ it~ back~ please~ open~ an~ issue~ on~ \\ 21 | https://github.com/cgnieder/acro/issues 22 | \tl_if_blank:nF {#3} { \\ #3 } 23 | } 24 | 25 | % ---------------------------------------------------------------------------- 26 | % #1: type 27 | % #2: old 28 | % #3: new 29 | \cs_new_protected:Npn \__acro_deprecation_warning:nnn #1#2#3 30 | { \msg_warning:nnnnn {acro} {deprecated} {#1} {#2} {#3} } 31 | \cs_generate_variant:Nn \__acro_deprecation_warning:nnn {nne,nV} 32 | 33 | \acro_attribute_new:n {deprecated} 34 | \acro_attribute_new:n {removed} 35 | 36 | \prg_new_conditional:Npnn \acro_if_deprecated:n #1 {p,T,F,TF} 37 | { 38 | \acro_attribute_if_set:nnTF {deprecated} {#1} 39 | { \prg_return_true: } 40 | { \prg_return_false: } 41 | } 42 | 43 | \prg_new_conditional:Npnn \acro_if_removed:n #1 {p,T,F,TF} 44 | { 45 | \acro_attribute_if_set:nnTF {removed} {#1} 46 | { \prg_return_true: } 47 | { \prg_return_false: } 48 | } 49 | 50 | % #1: old 51 | % #2: new 52 | \cs_new_protected:Npn \acro_deprecate:nn #1#2 53 | { \acro_attribute_set:nnn {deprecated} {#1} {#2} } 54 | 55 | % #1: old 56 | \cs_new_protected:Npn \acro_remove:n #1 57 | { \acro_attribute_set:nnn {removed} {#1} {} } 58 | 59 | % #1: type 60 | % #2: old 61 | \cs_new_protected:Npn \acro_deprecation_warning:nn #1#2 62 | { 63 | \__acro_deprecation_warning:nne 64 | {#1} 65 | {#2} 66 | { \acro_attribute_get:nn {deprecated} {#2} } 67 | } 68 | 69 | % #1: type 70 | % #2: old 71 | % #3: additional text 72 | \cs_new_protected:Npn \acro_removal_warning:nnn #1#2#3 73 | { \msg_warning:nnnnn {acro} {removed} {#1} {#2} {#3} } 74 | \cs_generate_variant:Nn \acro_removal_warning:nnn {nV} 75 | 76 | % #1: type 77 | % #2: old 78 | \cs_new_protected:Npn \acro_removal_warning:nn #1#2 79 | { \msg_warning:nnnn {acro} {removed} {#1} {#2} } 80 | \cs_generate_variant:Nn \acro_removal_warning:nn {nV} 81 | 82 | % ---------------------------------------------------------------------------- 83 | % #1: id 84 | % #2: property 85 | % #3: value 86 | \cs_set_protected:Npn \__acro_property_set:nnn #1#2#3 87 | { 88 | \acro_if_deprecated:nT {#2} 89 | { 90 | \acro_deprecation_warning:nn {property} {#2} 91 | \__acro_property_remove_from_auxlist:ne {#1} 92 | { \acro_attribute_get:nn {deprecated} {#2} } 93 | \__acro_auxlist_add:en 94 | { \acro_attribute_get:nn {deprecated} {#2} } 95 | {#1=={#3}} 96 | \acro_attribute_set:enn 97 | { \acro_attribute_get:nn {deprecated} {#2} } 98 | {#1} {#3} 99 | } 100 | \acro_if_removed:nT {#2} 101 | { \acro_removal_warning:nn {property} {#2} } 102 | \bool_lazy_and:nnT 103 | { ! \acro_if_deprecated_p:n {#2} } 104 | { ! \acro_if_removed_p:n {#2} } 105 | { 106 | \__acro_property_remove_from_auxlist:nn {#1} {#2} 107 | \__acro_auxlist_add:nn {#2} {#1=={#3}} 108 | \acro_attribute_set:nnn {#2} {#1} {#3} 109 | } 110 | } 111 | 112 | \cs_generate_variant:Nn \acro_attribute_set:nnn {e} 113 | \cs_generate_variant:Nn \__acro_auxlist_add:nn {e} 114 | \cs_generate_variant:Nn \__acro_property_remove_from_auxlist:nn {ne} 115 | 116 | % #1: old 117 | % #2: new 118 | \cs_new_protected:Npn \acro_deprecated_property:nn #1#2 119 | { 120 | \acro_deprecate:nn {#1} {#2} 121 | \acro_property_declare:nn {} {#1} 122 | } 123 | 124 | % #1: old 125 | \cs_new_protected:Npn \acro_removed_property:n #1 126 | { 127 | \acro_remove:n {#1} 128 | \acro_property_declare:nn {} {#1} 129 | } 130 | 131 | % ---------------------------------------------------------------------------- 132 | % #1: old 133 | % #2: new 134 | \cs_new_protected:Npn \acro_deprecate_function:NN #1#2 135 | { 136 | \cs_set_protected:Npn #1 137 | { 138 | \msg_error:nnnn {acro} {deprecated-function} {#1} {#2} 139 | #2 140 | } 141 | } 142 | 143 | % #1: old 144 | \cs_new_protected:Npn \acro_remove_function:N #1 145 | { 146 | \cs_set_protected:Npn #1 147 | { \msg_error:nnn {acro} {removed-function} {#1} } 148 | } 149 | 150 | % ---------------------------------------------------------------------------- 151 | % #1: new 152 | % #2: value 153 | \cs_new_protected:Npn \acro_deprecate_option:nn #1#2 154 | { 155 | \__acro_deprecation_warning:nVn {option} \l_keys_key_str {#1} 156 | \keys_set:nn {acro} { #1 = #2 } 157 | } 158 | 159 | % #1: additional text 160 | \cs_new_protected:Npn \acro_remove_option:n #1 161 | { \acro_removal_warning:nVn {option} \l_keys_key_str {#1} } 162 | 163 | \cs_new_protected:Npn \acro_remove_option: 164 | { \acro_removal_warning:nV {option} \l_keys_key_str } 165 | 166 | % ---------------------------------------------------------------------------- 167 | % old properties: 168 | \acro_deprecated_property:nn {accsupp} {short-acc} 169 | \acro_deprecated_property:nn {tooltip} {pdfcomment} 170 | \acro_deprecated_property:nn {class} {tag} 171 | \acro_deprecated_property:nn {foreign-lang} {foreign-babel} 172 | 173 | \acro_removed_property:n {long-pre} 174 | \acro_removed_property:n {after-citation} 175 | \acro_removed_property:n {index-cmd} 176 | \acro_removed_property:n {single-format} 177 | 178 | % ---------------------------------------------------------------------------- 179 | % old functions 180 | \acro_remove_function:N \acflike 181 | \acro_remove_function:N \acfplike 182 | \acro_remove_function:N \acsingle 183 | \acro_remove_function:N \Acsingle 184 | \acro_remove_function:N \acpsingle 185 | \acro_remove_function:N \Acpsingle 186 | 187 | \acro_remove_function:N \acpdfstring 188 | \acro_remove_function:N \acpdfstringplural 189 | \acro_remove_function:N \AcroRegisterTrailing 190 | 191 | \acro_deprecate_function:NN \acifused \acroifusedTF 192 | \acro_deprecate_function:NN \aciffirst \acroiffirstTF 193 | \acro_deprecate_function:NN \ProvideAcroEnding \DeclareAcroEnding 194 | 195 | \acro_remove_function:N \DeclareAcroListStyle 196 | \acro_remove_function:N \DeclareAcroListHeading 197 | \acro_remove_function:N \DeclareAcroFirstStyle 198 | \acro_remove_function:N \DeclareAcroExtraStyle 199 | \acro_remove_function:N \DeclareAcroPageStyle 200 | \acro_remove_function:N \AcroRegisterTrailing 201 | 202 | % ---------------------------------------------------------------------------- 203 | % old options: 204 | \keys_define:nn {acro} 205 | { 206 | %%% package: 207 | log .code:n = 208 | \acro_remove_option:n 209 | { You~ can~ use~ \acshow ~ to~ inspect~ an~ acronym~ instead . } , 210 | messages .code:n = \acro_remove_option: , 211 | macros .code:n = \acro_remove_option: , 212 | xspace .code:n = \acro_remove_option: , 213 | strict .code:n = \acro_remove_option: , 214 | %%% behaviour: 215 | hyperref .code:n = 216 | \acro_deprecate_option:nn {make-links} {true} , 217 | label .code:n = 218 | \acro_deprecate_option:nn {labels} {true} , 219 | only-used .code:n = 220 | \acro_deprecate_option:nn {list/display} {used} , 221 | mark-as-used .code:n = 222 | \acro_deprecate_option:nn {use-only-first} {true} , 223 | sort .code:n = 224 | \acro_deprecate_option:nn {list/sort} {true} , 225 | display-foreign .code:n = 226 | \acro_deprecate_option:nn {foreign/display} {#1} , 227 | cite .code:n = 228 | \acro_deprecate_option:nn {cite/display} {#1} , 229 | cite-cmd .code:n = 230 | \acro_deprecate_option:nn {cite/cmd} {#1} , 231 | group-citation .code:n = 232 | \acro_deprecate_option:nn {cite/group} {true} , 233 | cite-connect .code:n = 234 | \acro_deprecate_option:nn {cite/pre} {#1} , 235 | group-cite-connect .code:n = 236 | \acro_deprecate_option:nn {cite/group/pre} {#1} , 237 | group-cite-cmd .code:n = 238 | \acro_remove_option:n {Maybe~ the~ option~ `cite/cmd'~ helps.} , 239 | index .code:n = 240 | \acro_deprecate_option:nn {index/use} {true} , 241 | index-cmd .code:n = 242 | \acro_deprecate_option:nn {index/cmd} {#1} , 243 | short-format .code:n = 244 | \acro_deprecate_option:nn {format/short} {#1} , 245 | long-format .code:n = 246 | \acro_deprecate_option:nn {format/long} {#1} , 247 | foreign-format .code:n = 248 | \acro_deprecate_option:nn {format/foreign} {#1} , 249 | extra-format .code:n = 250 | \acro_deprecate_option:nn {format/extra} {#1} , 251 | single-format .code:n = \acro_remove_option: , 252 | single-form .code:n = 253 | \acro_deprecate_option:nn {single-style} {#1} , 254 | first-long-format .code:n = 255 | \acro_deprecate_option:nn {format/first-long} {#1} , 256 | list-short-format .code:n = \acro_remove_option: , 257 | list-short-width .code:n = \acro_remove_option: , 258 | list-long-format .code:n = 259 | \acro_deprecate_option:nn {format/list} {#1} , 260 | list-foreign-format .code:n = \acro_remove_option: , 261 | override-list-format .code:n = \acro_remove_option: , 262 | format-include-endings .code:n = 263 | \acro_deprecate_option:nn {include-endings} {true} , 264 | extra-style .code:n = \acro_remove_option: , 265 | page-style.code:n = \acro_remove_option: , 266 | pages .code:n = 267 | \acro_deprecate_option:nn {pages/display} {#1} , 268 | page-name .code:n = \acro_remove_option: , 269 | pages-name .code:n = \acro_remove_option: , 270 | following-page .code:n = 271 | \acro_deprecate_option:nn {pages/seq} {true} , 272 | following-pages .code:n = 273 | \acro_deprecate_option:nn {pages/seq} {true} , 274 | next-page .code:n = \acro_remove_option: , 275 | next-pages .code:n = \acro_remove_option: , 276 | uc-cmd .code:n = 277 | \acro_deprecate_option:nn {uppercase/cmd} {#1} , 278 | uppercase-short .code:n = 279 | \acro_deprecate_option:nn {uppercase/short} {#1} , 280 | tooltip .code:n = 281 | \acro_deprecate_option:nn {pdfcomments/use} {#1} , 282 | tooltip-cmd .code:n = 283 | \acro_deprecate_option:nn {pdfcomments/cmd} {#1} , 284 | use-barriers .code:n = \acro_remove_option: , 285 | reset-at-barriers .code:n = 286 | \acro_deprecate_option:nn {barriers/reset} {#1} , 287 | activate-trailing-tokens .code:n = 288 | \acro_deprecate_option:nn {trailing/activate} {#1} , 289 | deactivate-trailing-tokens .code:n = 290 | \acro_deprecate_option:nn {trailing/deactivate} {#1} , 291 | %%% list options: 292 | list-style .code:n = 293 | \acro_deprecate_option:nn {list/template} {#1} , 294 | list-heading .code:n = 295 | \acro_deprecate_option:nn {list/heading} {#1} , 296 | list-name .code:n = 297 | \acro_deprecate_option:nn {list/name} {#1} , 298 | list-caps .code:n = \acro_remove_option: , 299 | print-acronyms/include-classes .code:n = 300 | \acro_deprecate_option:nn {list/include} {#1} , 301 | print-acronyms/exclude-classes .code:n = 302 | \acro_deprecate_option:nn {list/exclude} {#1} , 303 | print-acronyms/name .code:n = 304 | \acro_deprecate_option:nn {list/name} {#1} , 305 | print-acronyms/heading .code:n = 306 | \acro_deprecate_option:nn {list/heading} {#1} , 307 | print-acronyms/sort .code:n = 308 | \acro_deprecate_option:nn {list/sort} {true} , 309 | print-acronyms/local-to-barriers .code:n = 310 | \acro_deprecate_option:nn {list/local} {true} 311 | } 312 | 313 | % ---------------------------------------------------------------------------- 314 | \AcroModuleEnd 315 | -------------------------------------------------------------------------------- /doc/acro-manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgnieder/acro/9a56e414b0eb82ff89241decc66da9620f2292df/doc/acro-manual.pdf -------------------------------------------------------------------------------- /doc/examples/acro.example.acflike.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgnieder/acro/9a56e414b0eb82ff89241decc66da9620f2292df/doc/examples/acro.example.acflike.pdf -------------------------------------------------------------------------------- /doc/examples/acro.example.acflike.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage[ngerman]{babel} 3 | \usepackage{acro} 4 | \acsetup{format/long=\itshape} 5 | 6 | \DeclareAcronym{cd}{short = CD, long = Compact Disc} 7 | 8 | \RenewAcroCommand\acflike{mm}{% 9 | \acroformat{long}{#2} (\UseAcroTemplate{short}{#1})% 10 | } 11 | 12 | \begin{document} 13 | 14 | \ac{cd} \par 15 | \acflike{cd}{Rohling} 16 | 17 | \end{document} 18 | -------------------------------------------------------------------------------- /doc/examples/acro.example.basic.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgnieder/acro/9a56e414b0eb82ff89241decc66da9620f2292df/doc/examples/acro.example.basic.pdf -------------------------------------------------------------------------------- /doc/examples/acro.example.basic.tex: -------------------------------------------------------------------------------- 1 | % this file is an adapted version of acrotest.tex shipped out 2 | % with the `acronym' package 3 | \documentclass{article} 4 | \usepackage[T1]{fontenc} 5 | \usepackage[english]{babel} 6 | \usepackage[colorlinks]{hyperref} 7 | \usepackage[version=3]{acro} 8 | 9 | \acsetup{ 10 | make-links , 11 | pages / display = first , 12 | pages / fill = {, } 13 | } 14 | 15 | \DeclareAcronym{CDMA}{ 16 | short = CDMA , 17 | long = Code Division Multiple Access , 18 | long-plural = es 19 | } 20 | \DeclareAcronym{GSM}{ 21 | short = GSM , 22 | long = Global System for Mobile communication 23 | } 24 | \DeclareAcronym{NA}{ 25 | short = {\ensuremath{N_{\mathrm{A}}}} , 26 | long = Number of Avogadro , 27 | extra = see \S\ref{Chem} , 28 | pdfstring = NA 29 | } 30 | \DeclareAcronym{NAD+}{ 31 | short = {NAD\textsuperscript{+}} , 32 | short-plural = , 33 | long = Nicotinamide Adenine Dinucleotide , 34 | pdfstring = NAD+ 35 | } 36 | \DeclareAcronym{NUA}{ 37 | short = NUA , 38 | long = Not Used Acronym 39 | } 40 | \DeclareAcronym{TDMA}{ 41 | short = TDMA , 42 | long = Time Division Multiple Access , 43 | long-plural = es 44 | } 45 | \DeclareAcronym{UA}{ 46 | short = UA , 47 | long = Used Acronym 48 | } 49 | \DeclareAcronym{lox}{ 50 | short = {\emph{LOX}} , 51 | long = Liquid Oxygen , 52 | pdfstring = LOX 53 | } 54 | \DeclareAcronym{lh2}{ 55 | short = {\emph{LH\textsubscript{2}}} , 56 | long = Liquid Hydrogen , 57 | pdfstring = LH2 58 | } 59 | \DeclareAcronym{IC}{ 60 | short = IC , 61 | long = Integrated Circuit 62 | } 63 | \DeclareAcronym{BUT}{ 64 | short = BUT , 65 | long = Block Under Test , 66 | long-plural-form = Blocks Under Test 67 | } 68 | \begin{document} 69 | 70 | \section{Intro} 71 | In the early nineties, \acs{GSM} was deployed in many European 72 | countries. \ac{GSM} offered for the first time international 73 | roaming for mobile subscribers. The \acs{GSM}'s use of \ac{TDMA} as 74 | its communication standard was debated at length. And every now 75 | and then there are big discussion whether \ac{CDMA} should have 76 | been chosen over \ac{TDMA}. 77 | 78 | \section{Furthermore} 79 | \acresetall 80 | The reader could have forgotten all the nice acronyms, so we repeat the 81 | meaning again. 82 | 83 | If you want to know more about \acf{GSM}, \acf{TDMA}, \acf{CDMA} 84 | and other acronyms, just read a book about mobile communication. Just 85 | to mention it: There is another \ac{UA}, just for testing purposes! 86 | 87 | \begin{figure}[h] 88 | Figure 89 | \caption{A float also admits references like \ac{GSM} or \acf{CDMA}.} 90 | \end{figure} 91 | 92 | \subsection{Some chemistry and physics} 93 | \label{Chem} 94 | \ac{NAD+} is a major electron acceptor in the oxidation 95 | of fuel molecules. The reactive part of \ac{NAD+} is its nictinamide 96 | ring, a pyridine derivate. 97 | 98 | One mol consists of \acs{NA} atoms or molecules. There is a relation 99 | between the constant of Boltzmann and the \acl{NA}: 100 | \begin{equation} 101 | k = R/\acs{NA} 102 | \end{equation} 103 | 104 | \acl{lox}/\acl{lh2} (\acs{lox}/\acs{lh2}) 105 | 106 | \subsection{Some testing fundamentals} 107 | When testing \acp{IC}, one typically wants to identify functional 108 | blocks to be tested separately. The latter are commonly indicated as 109 | \acp{BUT}. To test a \ac{BUT} requires defining a testing strategy\dots 110 | 111 | \printacronyms 112 | 113 | \end{document} 114 | -------------------------------------------------------------------------------- /doc/examples/acro.example.issue-109.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgnieder/acro/9a56e414b0eb82ff89241decc66da9620f2292df/doc/examples/acro.example.issue-109.pdf -------------------------------------------------------------------------------- /doc/examples/acro.example.issue-109.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage[enable-debug]{expl3} 3 | \usepackage{hyperref} 4 | \usepackage[version=3]{acro} 5 | 6 | \acsetup{ 7 | pages/display=all , 8 | pages/seq=false 9 | } 10 | 11 | \DeclareAcronym{ny}{ 12 | short = NY , 13 | long = New York , 14 | } 15 | 16 | \NewAcroCommand\aci{m}{} 17 | 18 | \begin{document} 19 | 20 | no\aci{ny}thing\newpage 21 | \ac{ny} 22 | 23 | \printacronyms 24 | 25 | \end{document} 26 | -------------------------------------------------------------------------------- /doc/examples/acro.example.issue-111.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgnieder/acro/9a56e414b0eb82ff89241decc66da9620f2292df/doc/examples/acro.example.issue-111.pdf -------------------------------------------------------------------------------- /doc/examples/acro.example.issue-111.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage[T1]{fontenc} 3 | \usepackage[french]{babel} 4 | \usepackage[version=3]{acro} 5 | 6 | \DeclareAcroArticle{definite}{\nospace} 7 | 8 | \NewAcroCommand\dacs{m}{\acrodefinite\UseAcroTemplate{short}{#1}} 9 | \NewAcroCommand\Dacs{m}{\acroupper\acrodefinite\UseAcroTemplate{short}{#1}} 10 | \NewAcroCommand\dacl{m}{\acrodefinite\UseAcroTemplate{long}{#1}} 11 | \NewAcroCommand\Dacl{m}{\acroupper\acrodefinite\UseAcroTemplate{long}{#1}} 12 | 13 | \DeclareAcronym{hadopi}{ 14 | short = HADOPI , 15 | long = Haute Autorit\'{e} pour la diffusion des \oe uvres et la protection des 16 | droits sur l’Internet , 17 | short-definite = l'\nospace , 18 | long-definite = la , 19 | } 20 | 21 | \begin{document} 22 | 23 | \dacs{hadopi} 24 | 25 | \Dacl{hadopi} 26 | 27 | \end{document} 28 | -------------------------------------------------------------------------------- /doc/examples/acro.example.issue-119.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgnieder/acro/9a56e414b0eb82ff89241decc66da9620f2292df/doc/examples/acro.example.issue-119.pdf -------------------------------------------------------------------------------- /doc/examples/acro.example.issue-119.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{acro}[=v3] 3 | 4 | \makeatletter 5 | \NewAcroTemplate[list]{external}{% 6 | \if@filesw 7 | \newwrite\acro@list 8 | \immediate\openout\acro@list\jobname.ac\relax 9 | \immediate\write\acro@list{\string\begin{description}} 10 | \let\item\relax 11 | \acronymsmapF{% 12 | \immediate\write\acro@list{% 13 | \space\space 14 | \item[\acrofield{##1}{short}] 15 | \acrofield{##1}{list}% 16 | \acroiffieldTF{##1}{extra}{ (\acrofield{##1}{extra})}{}% 17 | }% 18 | }{\immediate\write\acro@list{\item}\AcroRerun}% 19 | \immediate\write\acro@list{\string\end{description}} 20 | \immediate\closeout\acro@list 21 | \fi 22 | } 23 | \makeatother 24 | 25 | \DeclareAcronym{ny}{ 26 | short = NY , 27 | long = New York , 28 | } 29 | 30 | \DeclareAcronym{la}{ 31 | short = LA , 32 | long = Los Angeles , 33 | extra = City of Angels 34 | } 35 | 36 | \DeclareAcronym{dc}{ 37 | short = D.C. , 38 | long = Washington D.C. 39 | } 40 | 41 | \begin{document} 42 | 43 | \acuseall 44 | \printacronyms[template=external] 45 | \null 46 | 47 | \end{document} 48 | -------------------------------------------------------------------------------- /doc/examples/acro.example.issue-154.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgnieder/acro/9a56e414b0eb82ff89241decc66da9620f2292df/doc/examples/acro.example.issue-154.pdf -------------------------------------------------------------------------------- /doc/examples/acro.example.issue-154.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | 3 | \usepackage[version=3]{acro} 4 | 5 | \RenewAcroCommand\ac{mo}{\UseAcroTemplate{first}{#1}\IfNoValueF{#2}{#2}} 6 | 7 | \DeclareAcronym{uc}{ 8 | short = UC , 9 | long = Universal Composability , 10 | cite = xxx 11 | } 12 | 13 | \begin{document} 14 | 15 | We use the \ac{uc}[ model] for\dots 16 | 17 | \end{document} 18 | -------------------------------------------------------------------------------- /doc/examples/acro.example.possessive.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgnieder/acro/9a56e414b0eb82ff89241decc66da9620f2292df/doc/examples/acro.example.possessive.pdf -------------------------------------------------------------------------------- /doc/examples/acro.example.possessive.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | 3 | \usepackage[version=3]{acro} 4 | 5 | \DeclareAcroEnding{possessive}{'s}{'s} 6 | 7 | \NewAcroCommand\acg{m}{\acropossessive\UseAcroTemplate{first}{#1}} 8 | \NewAcroCommand\acsg{m}{\acropossessive\UseAcroTemplate{short}{#1}} 9 | \NewAcroCommand\aclg{m}{\acropossessive\UseAcroTemplate{long}{#1}} 10 | \NewAcroCommand\acfg{m}{% 11 | \acrofull 12 | \acropossessive 13 | \UseAcroTemplate{first}{#1}% 14 | } 15 | \NewAcroCommand\iacsg{m}{% 16 | \acroindefinite 17 | \acropossessive 18 | \UseAcroTemplate{short}{#1}% 19 | } 20 | 21 | \DeclareAcronym{MP}{ 22 | short = MP , 23 | long = Member of Parliament , 24 | long-plural-form = Members of Parliament , 25 | long-possessive-form = Member's of Parliament 26 | } 27 | 28 | \begin{document} 29 | 30 | \acg{MP} \par 31 | \acsg{MP} \par 32 | \aclg{MP} \par 33 | \acfg{MP} \par 34 | \iacsg{MP} \par 35 | 36 | \end{document} 37 | -------------------------------------------------------------------------------- /doc/examples/acro.example.texsx-505891.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgnieder/acro/9a56e414b0eb82ff89241decc66da9620f2292df/doc/examples/acro.example.texsx-505891.pdf -------------------------------------------------------------------------------- /doc/examples/acro.example.texsx-505891.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | 3 | \usepackage{acro} 4 | 5 | \DeclareAcroProperty{alt2} 6 | \DeclareAcroProperty{alt2-format} 7 | 8 | \RenewAcroTemplate[list]{description}{% 9 | \acroheading 10 | \acropreamble 11 | \begin{description} 12 | \acronymsmapF{ 13 | \item [% 14 | \acrowrite{short}% 15 | \acroifT{alt}{/}\acrowrite{alt}% 16 | \acroifT{alt2}{/}\acrowrite{alt2}% 17 | ] 18 | \acrowrite{list}% 19 | \acroifanyT{foreign,extra}{ (}% 20 | \acroifT{foreign}{% 21 | \acrowrite{foreign}% 22 | \acroifT{foreign-short}{, \acrowrite{foreign-short}}% 23 | \acroifT{extra}{, }% 24 | }% 25 | \acrowrite{extra}% 26 | \acroifanyT{foreign,extra}{)}% 27 | \acropagefill 28 | \acropages 29 | {\acrotranslate{page}\nobreakspace}% 30 | {\acrotranslate{pages}\nobreakspace}% 31 | } 32 | { \item \AcroRerun } 33 | \end {description} 34 | } 35 | 36 | \DeclareAcronym{one}{ short = one , alt = two, alt2 = three, long = common description } 37 | \DeclareAcronym{four}{ short = four , long = another description } 38 | 39 | \begin{document} 40 | 41 | \printacronyms[display=all] 42 | 43 | \end{document} 44 | 45 | -------------------------------------------------------------------------------- /doc/examples/acro.example.texsx-507726.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgnieder/acro/9a56e414b0eb82ff89241decc66da9620f2292df/doc/examples/acro.example.texsx-507726.pdf -------------------------------------------------------------------------------- /doc/examples/acro.example.texsx-507726.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage[english,ngerman]{babel} 3 | \usepackage{csquotes} 4 | \usepackage{acro} 5 | 6 | % issue #136 7 | \DeclareAcroProperty{foreign-short} 8 | 9 | \RenewAcroTemplate{long-short}{% 10 | \acroiffirstTF{% 11 | \acrowrite{long}\acspace 12 | (% 13 | \acrowrite{short}% 14 | \acroifT{foreign}{, }% 15 | \acrowrite{foreign}% 16 | \acroifT{foreign-short}{, }% 17 | \acrowrite{foreign-short}% 18 | \acrogroupcite 19 | )% 20 | } 21 | {\acrowrite{short}}% 22 | } 23 | 24 | \RenewAcroTemplate[list]{description}{% 25 | \acroheading 26 | \acropreamble 27 | \begin{description} 28 | \acronymsmapF{ 29 | \item [\acrowrite{short}\acroifT{alt}{/\acrowrite{alt}}] 30 | \acrowrite{long}% 31 | \acroifanyT{foreign,extra,foreign-short}{ (}% 32 | \acrowrite{foreign}% 33 | \acroifallT{foreign-short,foreign}{, }% 34 | \acrowrite{foreign-short}% 35 | \acroifanyT{foreign-short,foreign}{\acroifT{extra}{, }}% 36 | \acrowrite{extra}% 37 | \acroifanyT{foreign,extra,foreign-short}{)}% 38 | \acroifpagesT{% 39 | \acropagefill 40 | \acropages 41 | {\acrotranslate{page}\nobreakspace}% 42 | {\acrotranslate{pages}\nobreakspace}% 43 | }% 44 | } 45 | { \item \AcroRerun } 46 | \end {description} 47 | } 48 | 49 | \DeclareAcronym{dsgvo}{ 50 | short = DSGVO, 51 | long = {Datenschutz-Grundverordnung}, 52 | foreign = General Data Protection Regulation , 53 | foreign-short = GDPR, % new line 54 | foreign-babel = english, 55 | foreign-format = \enquote 56 | } 57 | 58 | \begin{document} 59 | 60 | \ac{dsgvo} 61 | 62 | \printacronyms 63 | 64 | \end{document} 65 | -------------------------------------------------------------------------------- /doc/examples/acro.example.texsx-513623.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgnieder/acro/9a56e414b0eb82ff89241decc66da9620f2292df/doc/examples/acro.example.texsx-513623.pdf -------------------------------------------------------------------------------- /doc/examples/acro.example.texsx-513623.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{acro} 3 | 4 | \newrobustcmd*\newspecies[4][]{% 5 | \DeclareAcronym{#2}{ 6 | short = {#3} , 7 | long = {#4} , 8 | #1 , 9 | tag = species , 10 | first-style= long , 11 | format = \itshape 12 | }% 13 | } 14 | \newspecies{ecoli}{E.~coli}{Escherichia coli} 15 | 16 | \begin{document} 17 | 18 | First use: \ac{ecoli}\par 19 | Second use: \ac{ecoli} 20 | 21 | \end{document} 22 | -------------------------------------------------------------------------------- /doc/examples/acro.example.texsx-515295.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgnieder/acro/9a56e414b0eb82ff89241decc66da9620f2292df/doc/examples/acro.example.texsx-515295.pdf -------------------------------------------------------------------------------- /doc/examples/acro.example.texsx-515295.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | 3 | \usepackage{acro} 4 | \usepackage{csquotes} 5 | \usepackage{chemmacros} 6 | 7 | \DeclareAcronym{APA}{ 8 | short = 3-APA , 9 | long = \iupac{3-azido-1-propyl|amine} 10 | } 11 | \DeclareAcronym{CuAAC}{ 12 | short = \enquote{click} chemistry , 13 | long = copper(I)-catalyzed azide-alkyne cycloaddition 14 | } 15 | 16 | \begin{document} 17 | 18 | 1: \Acl{APA} 19 | 20 | 2: \Acs{CuAAC} 21 | 22 | 3: \Acl{CuAAC} 23 | 24 | \end{document} 25 | -------------------------------------------------------------------------------- /doc/examples/acro.example.texsx-542461.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgnieder/acro/9a56e414b0eb82ff89241decc66da9620f2292df/doc/examples/acro.example.texsx-542461.pdf -------------------------------------------------------------------------------- /doc/examples/acro.example.texsx-542461.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{acro} 3 | 4 | \DeclareAcroArticle{definite}{the} 5 | \DeclareAcroEnding{possessive}{'s}{'s} 6 | 7 | \NewAcroCommand\dac{m}{\acrodefinite\UseAcroTemplate{first}{#1}} 8 | \NewAcroCommand\Dac{m}{\acroupper\acrodefinite\UseAcroTemplate{first}{#1}} 9 | 10 | \NewAcroCommand\Dacg{m}{% 11 | \acroupper 12 | \acrodefinite 13 | \acropossessive 14 | \UseAcroTemplate{first}{#1}% 15 | } 16 | 17 | \DeclareAcronym{css}{ 18 | short = CSS , 19 | long = Centre for Spaghetti Studies , 20 | short-definite = \nospace , 21 | long-possessive = ' 22 | } 23 | 24 | \begin{document} 25 | 26 | Bob hails from \dac{css}. \par 27 | Bob hails from \dac{css}. 28 | 29 | \acreset{css} 30 | 31 | \Dacg{css} mandate is broad. \par 32 | \Dacg{css} mandate is broad. 33 | 34 | \acreset{css} 35 | 36 | \Dac{css} scientists eat well. \par 37 | \Dac{css} scientists eat well. \par 38 | 39 | \end{document} 40 | -------------------------------------------------------------------------------- /doc/examples/acro.example.units.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cgnieder/acro/9a56e414b0eb82ff89241decc66da9620f2292df/doc/examples/acro.example.units.pdf -------------------------------------------------------------------------------- /doc/examples/acro.example.units.tex: -------------------------------------------------------------------------------- 1 | \documentclass{scrartcl} 2 | \usepackage[T1]{fontenc} 3 | \usepackage[ngerman]{babel} 4 | \usepackage[version=3]{acro} 5 | 6 | \acsetup{ list/display = all , pages/display = all} 7 | 8 | \usepackage{longtable,siunitx} 9 | 10 | \DeclareAcronym{ecm}{ 11 | short = ECM , 12 | long = Electro Chemical Machining , 13 | extra = Elektrochemisches Abtragen 14 | } 15 | \DeclareAcronym{adc}{ 16 | short = ADC , 17 | long = Analog-to-Digital-Converter 18 | } 19 | \DeclareAcronym{edm}{ 20 | short = EDM , 21 | long = Electro Discharge Machining 22 | } 23 | \DeclareAcronym{ecdm}{ 24 | short = ECDM , 25 | long = Electro Chemical Discharge Machining , 26 | extra = Kombination aus \acs*{ecm} und \acs*{edm} 27 | } 28 | 29 | \DeclareAcroProperty{unit} 30 | 31 | % "Acronyme" (tatsächlich physikalische Größen) einer speziellen Klasse: 32 | \DeclareAcronym{f}{ 33 | short = \ensuremath{f} , 34 | long = Frequenz , 35 | unit = \si{\hertz} , 36 | tag = physics 37 | } 38 | \DeclareAcronym{A}{ 39 | short = \ensuremath{A} , 40 | long = Fläche , 41 | unit = \si{\metre^2} , 42 | tag = physics 43 | } 44 | \DeclareAcronym{C}{ 45 | short = \ensuremath{C} , 46 | long = Kapazität , 47 | unit = \si{\farad} , 48 | tag = physics 49 | } 50 | \DeclareAcronym{F}{ 51 | short = \ensuremath{F} , 52 | long = Kraft , 53 | unit = \si{\newton} , 54 | tag = physics 55 | } 56 | 57 | \NewAcroTemplate[list]{physics}{% 58 | \acronymsmapT{% 59 | \AcroAddRow{% 60 | \acrowrite{short}% 61 | & 62 | \acrowrite{unit}% 63 | & 64 | \acrowrite{list}% 65 | & 66 | \acropages 67 | {\acrotranslate{page}\nobreakspace}% 68 | {\acrotranslate{pages}\nobreakspace}% 69 | \tabularnewline 70 | }% 71 | }% 72 | \acroheading 73 | \acropreamble 74 | \par\noindent 75 | \setlength\LTleft{0pt}% 76 | \setlength\LTright{0pt}% 77 | \begin{longtable}{@{}lll@{\extracolsep{\fill}}l@{}} 78 | \AcronymTable 79 | \end{longtable} 80 | } 81 | 82 | \begin{document} 83 | 84 | erstes Mal: \ac{ecm} 85 | 86 | zweites Mal: \ac{ecm} 87 | 88 | \ac{F} 89 | 90 | % % alle außer der Klasse 'physics' auflisten: 91 | \printacronyms[exclude=physics]%, name=Abkürzungsverzeichnis] 92 | 93 | % nur die Klasse 'physics' auflisten: 94 | \printacronyms[template=physics, include=physics]%, name=Formelverzeichnis] 95 | 96 | \end{document} 97 | --------------------------------------------------------------------------------