当有分页符时,如何将引文正好放在数字下面?

时间:2017-12-25 11:05:25

标签: r latex r-markdown pandoc

由于我的prior question没有可行的解决方案,我试着将引文正好放在一个数字下面。这可以工作,直到该图经历自动分页。然后,引用被放置在我想放置图形的位置,但是图形本身出现在下一页并且两者都分开。有谁知道补救措施?

这是我的代码和截图:

---
title: "Test"
output:
  pdf_document: default
references:
- id: hawking_thermodynamics_1983
  author:
  - family: Hawking
    given: S. W.
  - family: Page
    given: Don. N.
  publisher: Communications in Mathematical Physics
  title: Thermodynamics of Black Holes in Anti-de Sitter Space.
  volume: 87
  type: article-journal
  issued:
    year: 1983
header-includes:
- \usepackage{lipsum}  # just used for producing example text in document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Headline
\lipsum[1-5]

\begin{figure}[h]
\centering
\includegraphics[width=10cm]{example.png}
\caption{Example figure}\label{fig1}
\end{figure}
[source: @hawking_thermodynamics_1983]

\lipsum[1-4]

## Bibliography

编辑:这适用于* .bib版本:

@article{hawking_thermodynamics_1983,
    title = {Thermodynamics of black holes in anti-de Sitter space},
    volume = {87},
    pages = {577--588},
    number = {4},
    journaltitle = {Communications in Mathematical Physics},
    author = {Hawking, S. W. and Page, Don N.},
    date = {1983-12},
}

enter image description here

2 个答案:

答案 0 :(得分:3)

您可以将[source: <cite>]作为figure

的一部分加入
\begingroup
\figure[h]
  \centering
  \includegraphics[width=10cm]{example.png}
  \caption{Example figure}\label{fig1}
  [source: @hawking_thermodynamics_1983]
\endfigure
\endgroup

以上模拟了\begin{figure}[h] ... \end{figure}建议的相同分组,但没有明确使用figure 环境; Rmarkdown进程跳过并假设LaTeX环境中的所有内容(如figure)将包含仅限LaTeX的代码,因此它无法识别markdown语法[source: @<cite>],而是抱怨<cite>包含下划线,只能在数学模式中使用。

或者,如果必须,请将float package添加到您的YAML前言

header-includes:
- <other packages>
- \usepackage{float}

然后使用[H] float说明符要求float保持H ere:

\begin{figure}[H]
  \centering
  \includegraphics[width=10cm]{example.png}
  \caption{Example figure}\label{fig1}
\end{figure}
[source: @hawking_thermodynamics_1983]

请注意,如果浮动不适合页面,这将破坏文本的常规设置。

答案 1 :(得分:0)

当您使用bib文件时,可以使用stackengine包和\cite{}

\usepackage{stackengine}

% ....

\begin{figure}[h]
\centering
\stackunder[5pt]{\includegraphics[width=10cm]{unnamed.png}}{\cite{hawking_thermodynamics_1983}}%
\caption{Example figure}\label{fig1}
\end{figure}

enter image description here