【问题标题】:bibtex citations in rst2latexrst2latex 中的 bibtex 引用
【发布时间】:2012-07-14 10:51:01
【问题描述】:

使用 rst2latex,哪个命令允许我包含引用 bibtex 数据库的引用键? 在乳胶中,我会用 \cite{Rumpelstielzchen2003}

实现这一点

【问题讨论】:

    标签: restructuredtext


    【解决方案1】:

    我找到的解决方案是将乳胶内联到第一个文档中:

    .. role:: raw-tex(raw)
        :format: latex html
    
    Introduction
    ============
    A profit maximizing agent in an environment with a finite number of buyers
    following :raw-tex:`\cite{Kutschinski2003}` investigates price setting by 
    reinforcement learning agent.
    
    # at the end of the document
    .. raw:: latex
    
        \bibliographystyle{plain}
        \bibliography{/home/path/library}
    

    文开头的角色定义让我们可以放纯latex 排队。使用 :raw-tex:\cite{Kutschinski2003} 我们索引乳胶参考 来自 bibtex 文件。在文档的末尾,我们放了一个原始的乳胶段落,以 .. raw:引用 library.bib 文件的乳胶。 (由 bibtex 或 mendeley 创建) 第一个文件可以编译:

    rst2latex paper.rst > build/paper.tex && cd build/ && latex paper.tex && bibtex paper.aux && latex paper.tex && pdflatex paper.tex && evince paper.pdf & cd .. 
    

    或者使用以下编译命令创建一个 paper.sh 文件:

    rst2latex paper.rst > build/paper.tex 
    cd build/
    latex paper.tex
    bibtex paper.aux
    latex paper.tex
    pdflatex paper.tex
    evince paper.pdf
    cd .. 
    

    (如果latex导致图片出现问题,请用pdflatex代替)

    【讨论】:

      【解决方案2】:

      另一种方法(虽然也是 LaTeX 特定的)是使它在编辑时更好。

      .. role:: cite
      
      .. raw:: latex
      
         \providecommand*\DUrolecite[1]{\cite{#1}}
      

      这样你就可以使用了

      :cite:`key`
      

      在您的文档末尾:

      .. raw:: latex
      
         \bibliographystyle{plain}
         \bibliography{/home/path/library}
      

      【讨论】:

      • 这会与我的解决方案结合使用还是如何找到库?
      • 与您的解决方案中的相同。为了完整起见,我将其添加到答案中。
      【解决方案3】:

      有一个非常方便的工具叫做 bib2reSTcitation 可以将 bibtex 样式引用文件转换为 reStructuredText Markup 样式引用样式。

      运行:

      $ python bib2reSTcitation.py -i tex.bib -o references.txt
      

      你得到你想要的。希望对您有所帮助!

      【讨论】:

      • bib2reSTcitation 似乎是一个大的正则表达式,它从 bibtex 文件中提取条目,但并没有真正将它们格式化为引用;我误解了它的作用吗? (比如好像把作者列表写成A and B and C and D,就像在bibTeX中一样,而且好像没有让你选择引用风格。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多