Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. begin{description}
  2. item[foo] foo is good
  3. item[bar] bar is bad
  4. end{description}
  5.  
  6. begin{description}
  7. item[foo] label{foo} foo is good
  8. ....
  9. end{description}
  10. ....
  11. For good things (see, for example ref{foo})...
  12.  
  13. newcounter{desccount}
  14. newcommand{descitem}[1]{%
  15. item[#1] refstepcounter{desccount}label{#1}
  16. }
  17. newcommand{descref}[1]{hyperref[#1]{#1}}
  18.  
  19. begin{description}
  20. descitem{foo} foo is good
  21. descitem{bar} bar is bad
  22. end{description}
  23. ...
  24. For good things (see, for example descref{foo})...
  25.  
  26. newcounter{foobarcounter}
  27. renewcommand{thefoobarcounter}
  28. {({ifcasevalue{foobarcounter}or fooor barelse ehhhfirelax})}
  29. begin{list}{thefoobarcounter}{usecounter{foobarcounter}}
  30. itemlabel{foodesc} Foo is good
  31. item Bar is bad
  32. item This list was not supposed to be this long
  33. end{list}
  34. ......
  35. .. Something good, see ref{foodesc}.
  36.  
  37. usepackage{amsmath}
  38. ...
  39. begin{equation}label{eq:energy}tag{Einstein}
  40. E=mc^2
  41. end{equation}
  42. ...
  43. Invoking the energy-mass equivalence of ref{eq:energy}
  44.  
  45. newcommand{foo}{foo}
  46. ....
  47. begin{description}
  48. item[foo] foo is good
  49. ....
  50. end{description}
  51. ....
  52. For good things (see, for example foo)...
  53.  
  54. newcounter{foocnt} %% define a counter
  55. setcounter{foocnt}{0} %% set the counter to some initial value (not really important)
  56. %%%% Parameters
  57. % #1: Title
  58. newenvironment{fooEnvironment}[1]
  59. {
  60. renewcommand{thefoocnt}{textbf{#1}} %% this is where the display of the counter is overwritten/modified
  61. refstepcounter{foocnt} %% increment counter (in this case we write the custom label/title to a temp. file which is read when the document resolves a ref)
  62. par %% start new paragraph (this is just an example for format modifications)
  63. textbf{#1:} %% display the title before the content of the environment is displayed
  64. }{
  65. par %% another paragraph after the environment
  66. }
  67.  
  68. begin{fooEnvironment}{foo}
  69. foo is good
  70. label{fooLabel}
  71. end{fooEnvironment}
  72. begin{fooEnvironment}{bar}
  73. bar is bad
  74. label{barLabel}
  75. end{fooEnvironment}
  76. For good things (see, for example ref{fooLabel})...
  77.  
  78. newcounter{desccount}
  79. newcommand{descitem}[1]{%
  80. refstepcounter{desccount}label{#1}%
  81. }
  82. newcommand{descref}[2][undefined]{%
  83. ifx#1undefined%
  84. hyperref[#2]{#2}%
  85. else%
  86. hyperref[#2]{#1}%
  87. fi%
  88. }%
  89.  
  90. descitem{linklabel} text next to label, you will be directed here...
  91.  
  92. newpage
  93. descref[after clicking on this optional text]{linklabel}
  94.  
  95. documentclass{article}
  96. usepackage{hyperref}
  97. begin{document}
  98. makeatletter
  99. newcommandmy@saved@item{}
  100. newcommandmydescriptionitem{}
  101. defmydescriptionitem[#1]{%
  102. my@saved@item[{csname phantomsectionendcsname#1}]%
  103. def@currentlabel{unexpanded{unexpanded{#1}}}%
  104. }%
  105. newenvironment{mydescription}%
  106. {%
  107. letmy@saved@item@item
  108. let@item=mydescriptionitem
  109. description
  110. }%
  111. {csname enddescriptionendcsname}
  112. makeatother
  113.  
  114. begin{mydescription}
  115. item[foo] label{foo} foo is good
  116. item[bar] label{bar} bar is bad
  117. end{mydescription}
  118.  
  119. For good things (see, for example ref{foo})dots
  120.  
  121. For bad things (see, for example ref{bar})dots
  122.  
  123. end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement