带下划线的引文中的换行符

带下划线的引文中的换行符

我一直在寻找解决方案自动突出显示对特定作者作品的引用 使用 biblatex,但问题仍然没有答案,而且我目前没有时间自己调查。

无论如何,我一直手动地在想要突出显示的引文下划线(作者姓名以小写字母打印,因此我不能只强调它们)。但是,这会导致行过满,因为下划线不允许在引文中换行。我使用了包中的\underline;两者都不会换行。 由于?的干扰,包中的会导致错误。\ulineulemulsoulbiblatex

有没有一种方法可以给引用加下划线并允许换行?

梅威瑟:

 \documentclass{article}
 \usepackage[latin9]{inputenc}
 %\usepackage{soul}
 \usepackage{ulem}

 \usepackage[style=authoryear-comp,natbib=true,%
 backend=biber]{biblatex}

 \usepackage{filecontents}
 \begin{filecontents}{\jobname.bib}
 @Book{Darwin.84,
   author =      {C. D\"{a}rwin},
   title =   {The different forms of flowers on plants of the same species},
   publisher =   {John Murray},
   address =      {London},
   edition =      2,
   year =    1884}

 @ARTICLE{Davies.pnas04,
 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.},
 TITLE = {D\"{a}rwin's abominable mystery: {Insights} from a supertree of the angiosperms.},
 JOURNAL = {Proc. Natl. Acad. Sci. U.S.A.},
 VOLUME = {101},
 PAGES = {1904--1909},
 YEAR = {2004},
 MONTH = Feb,
 NUMBER = {7}
 }

 @ARTICLE{Vamosi.el10,
 AUTHOR = {Vamosi, J. C. AND Vamosi, S. M.},
 TITLE = {Key innovations within a geographical context in flowering plants: towards resolving {D\"{a}rwin}'s abominable mystery.},
 JOURNAL = {Ecol. Lett.},
 VOLUME = {13},
 PAGES = {1270--1279},
 YEAR = {2010},
 MONTH = Oct,
 NUMBER = {10}
 }

 \end{filecontents}
 \addbibresource{\jobname.bib}


 \makeatother

 \begin{document}


 \citet{Davies.pnas04,Vamosi.el10} cite \uline{\citet{Darwin.84}}.

 %\citet{Davies.pnas04,Vamosi.el10} cite \ul{\citet{Darwin.84}}.

 \printbibliography

 \end{document}

答案1

对于 TeX 来说,下划线非常困难。特别是\underline永远不会中断。命令\uline\ul(来自ulemsoul)解除了此限制,但代价是要求它们的参数相对简单。像 这样的复杂宏\cite要么不允许换行(因为它们包含分组),要么根本不起作用。

我看到解决这个问题的唯一方法是使用 LuaTeX 使用下划线文本保罗·伊桑伯特\underline。 也可以看看如何在 biblatex 中为整个 bibitem 加下划线?

MWE 必须使用 LuaLaTeX 进行编译

\documentclass{article}

\usepackage[style=authoryear-comp, backend=biber]{biblatex}
\addbibresource{biblatex-examples.bib}

\usepackage{kantlipsum}
\usepackage[normalem]{ulem}
\usepackage{soul}

\newattribute{\ulattr}

\usepackage{luacode}
\begin{luacode}
local HLIST = node.id("hlist")
local RULE = node.id("rule")
local GLUE = node.id("glue")
local KERN = node.id("kern")
local ULATTR = luatexbase.attributes["ulattr"]

function get_lines(head)
  for line in node.traverse_id(HLIST, head) do
    underline(line.list, line.glue_order,
      line.glue_set, line.glue_sign)
  end
  luatexbase.remove_from_callback("post_linebreak_filter",
                                  "get_lines")
  return head
end

local function good_item(item)
  if item.id == GLUE and
    (item.subtype == node.subtype("leftskip")
     or item.subtype == node.subtype("rightskip")
     or item.subtype == node.subtype("parfillskip")) then
      return false
  else
    return true
  end
end

function underline(head, order, ratio, sign)
  local item = head
  while item do
    if node.has_attribute(item, ULATTR)
      and good_item(item) then
        local item_line = node.new(RULE)
        item_line.depth = tex.sp("1.4pt")
        item_line.height = tex.sp("-1pt")
        local end_node = item
        while end_node.next and
          good_item(end_node.next) and
          node.has_attribute(end_node.next, ULATTR) do
            end_node = end_node.next
        end
        item_line.width = node.dimensions
          (ratio, sign, order, item, end_node.next)
        local item_kern = node.new(KERN, 1)
        item_kern.kern = -item_line.width
        node.insert_after(head, end_node,        
                          item_kern)
        node.insert_after(head, item_kern,
                          item_line)
        item = end_node.next
    else
      item = item.next
    end
  end
end
\end{luacode}

\newcommand{\luaunderline}[1]{%
  \quitvmode
  \setattribute{\ulattr}{1}%
  #1%
  \unsetattribute{\ulattr}%
  \directlua{%
    luatexbase.add_to_callback("post_linebreak_filter",
                               get_lines, "get_lines")}%
}

\newcommand{\luaunderlineswitch}{%
  \quitvmode\setattribute{\ulattr}{1}%
  \directlua{%
    luatexbase.add_to_callback("post_linebreak_filter",
                               get_lines, "get_lines")}%
}

\begin{document}
  \textcite{sigfridsson,nussbaum} cite \underline{\textcite{sigfridsson}}.

  \textcite{sigfridsson,nussbaum} cite \uline{\textcite{sigfridsson}}.

%  \textcite{sigfridsson,nussbaum} cite \ul{\textcite{sigfridsson}}.% <- gives a error

  \textcite{sigfridsson,nussbaum} cite \luaunderline{\textcite{sigfridsson}}.

  \kant[1]
\end{document}

在此处输入图片描述

相关内容