Advertisement
csgillespie

instrumenter.tex

Aug 17th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. \RequirePackage{xparse}
  2.  
  3. \ExplSyntaxOn
  4.  
  5. \iow_new:N \l_csgillespie_iow
  6.  
  7. % #1: sectioning command name as a single token
  8. % #2: character tokens representing the command name, without the backslash
  9. \cs_new_protected:Npn \csgillespie_instrument_sec_cmd:Nn #1#2
  10. {
  11. % Save the original sectioning command
  12. \cs_gset_eq:cN { g_csgillespie_#2_orig: } #1
  13.  
  14. \RenewDocumentCommand #1 { s O{##3} m }
  15. {
  16. \iow_now:Nn \l_csgillespie_iow { #2 ; ##2 ; ##3 }
  17.  
  18. \IfBooleanTF {##1}
  19. { \use:c { g_csgillespie_#2_orig: } * {##3} }
  20. { \use:c { g_csgillespie_#2_orig: } [##2] {##3} }
  21. }
  22. }
  23.  
  24. \cs_generate_variant:Nn \csgillespie_instrument_sec_cmd:Nn { c }
  25.  
  26. % #1: character tokens representing the command name, without the backslash
  27. \cs_new_protected:Npn \csgillespie_instrument_sec_cmd_ifexists:n #1
  28. {
  29. \cs_if_exist:cT {#1}
  30. { \csgillespie_instrument_sec_cmd:cn {#1} {#1} }
  31. }
  32.  
  33. \AtBeginDocument
  34. {
  35. \iow_open:Nn \l_csgillespie_iow { sectioning.csv }
  36. \clist_map_inline:nn
  37. {
  38. chapter, url
  39. }
  40. { \csgillespie_instrument_sec_cmd_ifexists:n {#1} }
  41. }
  42.  
  43. \AtEndDocument { \iow_close:N \l_csgillespie_iow }
  44.  
  45. \ExplSyntaxOff
  46. \endinput
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement