Guest User

Untitled

a guest
Jun 24th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.95 KB | None | 0 0
  1. documentclass{article}
  2. usepackage[latin9]{inputenc}
  3. %usepackage{soul}
  4. usepackage{ulem}
  5.  
  6. usepackage[style=authoryear-comp,natbib=true,%
  7. backend=biber]{biblatex}
  8.  
  9. usepackage{filecontents}
  10. begin{filecontents}{jobname.bib}
  11. @Book{Darwin.84,
  12. author = {C. D"{a}rwin},
  13. title = {The different forms of flowers on plants of the same species},
  14. publisher = {John Murray},
  15. address = {London},
  16. edition = 2,
  17. year = 1884}
  18.  
  19. @ARTICLE{Davies.pnas04,
  20. AUTHOR = {Davies, T. J. AND Barraclough, T. G. AND Chase, M. W. AND Soltis, P. S. AND Soltis, D. E. AND D"{a}rwin, C.},
  21. TITLE = {D"{a}rwin's abominable mystery: {Insights} from a supertree of the angiosperms.},
  22. JOURNAL = {Proc. Natl. Acad. Sci. U.S.A.},
  23. VOLUME = {101},
  24. PAGES = {1904--1909},
  25. YEAR = {2004},
  26. MONTH = Feb,
  27. NUMBER = {7}
  28. }
  29.  
  30. @ARTICLE{Vamosi.el10,
  31. AUTHOR = {Vamosi, J. C. AND Vamosi, S. M.},
  32. TITLE = {Key innovations within a geographical context in flowering plants: towards resolving {D"{a}rwin}'s abominable mystery.},
  33. JOURNAL = {Ecol. Lett.},
  34. VOLUME = {13},
  35. PAGES = {1270--1279},
  36. YEAR = {2010},
  37. MONTH = Oct,
  38. NUMBER = {10}
  39. }
  40.  
  41. end{filecontents}
  42. addbibresource{jobname.bib}
  43.  
  44.  
  45. makeatother
  46.  
  47. begin{document}
  48.  
  49.  
  50. citet{Davies.pnas04,Vamosi.el10} cite uline{citet{Darwin.84}}.
  51.  
  52. %citet{Davies.pnas04,Vamosi.el10} cite ul{citet{Darwin.84}}.
  53.  
  54. printbibliography
  55.  
  56. end{document}
  57.  
  58. documentclass{article}
  59.  
  60. usepackage[style=authoryear-comp, backend=biber]{biblatex}
  61. addbibresource{biblatex-examples.bib}
  62.  
  63. usepackage{kantlipsum}
  64. usepackage[normalem]{ulem}
  65. usepackage{soul}
  66.  
  67. newattribute{ulattr}
  68.  
  69. usepackage{luacode}
  70. begin{luacode}
  71. local HLIST = node.id("hlist")
  72. local RULE = node.id("rule")
  73. local GLUE = node.id("glue")
  74. local KERN = node.id("kern")
  75. local ULATTR = luatexbase.attributes["ulattr"]
  76.  
  77. function get_lines(head)
  78. for line in node.traverse_id(HLIST, head) do
  79. underline(line.list, line.glue_order,
  80. line.glue_set, line.glue_sign)
  81. end
  82. luatexbase.remove_from_callback("post_linebreak_filter",
  83. "get_lines")
  84. return head
  85. end
  86.  
  87. local function good_item(item)
  88. if item.id == GLUE and
  89. (item.subtype == node.subtype("leftskip")
  90. or item.subtype == node.subtype("rightskip")
  91. or item.subtype == node.subtype("parfillskip")) then
  92. return false
  93. else
  94. return true
  95. end
  96. end
  97.  
  98. function underline(head, order, ratio, sign)
  99. local item = head
  100. while item do
  101. if node.has_attribute(item, ULATTR)
  102. and good_item(item) then
  103. local item_line = node.new(RULE)
  104. item_line.depth = tex.sp("1.4pt")
  105. item_line.height = tex.sp("-1pt")
  106. local end_node = item
  107. while end_node.next and
  108. good_item(end_node.next) and
  109. node.has_attribute(end_node.next, ULATTR) do
  110. end_node = end_node.next
  111. end
  112. item_line.width = node.dimensions
  113. (ratio, sign, order, item, end_node.next)
  114. local item_kern = node.new(KERN, 1)
  115. item_kern.kern = -item_line.width
  116. node.insert_after(head, end_node,
  117. item_kern)
  118. node.insert_after(head, item_kern,
  119. item_line)
  120. item = end_node.next
  121. else
  122. item = item.next
  123. end
  124. end
  125. end
  126. end{luacode}
  127.  
  128. newcommand{luaunderline}[1]{%
  129. quitvmode
  130. setattribute{ulattr}{1}%
  131. #1%
  132. unsetattribute{ulattr}%
  133. directlua{%
  134. luatexbase.add_to_callback("post_linebreak_filter",
  135. get_lines, "get_lines")}%
  136. }
  137.  
  138. newcommand{luaunderlineswitch}{%
  139. quitvmodesetattribute{ulattr}{1}%
  140. directlua{%
  141. luatexbase.add_to_callback("post_linebreak_filter",
  142. get_lines, "get_lines")}%
  143. }
  144.  
  145. begin{document}
  146. textcite{sigfridsson,nussbaum} cite underline{textcite{sigfridsson}}.
  147.  
  148. textcite{sigfridsson,nussbaum} cite uline{textcite{sigfridsson}}.
  149.  
  150. % textcite{sigfridsson,nussbaum} cite ul{textcite{sigfridsson}}.% <- gives a error
  151.  
  152. textcite{sigfridsson,nussbaum} cite luaunderline{textcite{sigfridsson}}.
  153.  
  154. kant[1]
  155. end{document}
Add Comment
Please, Sign In to add comment