0

In my markdown document I have a complex latex table with a caption, in which I would like to add a reference.

The table can be seen below...

\begin{table}[ht]
\captionof{table}{Some complex table \protect\hyperlink{ref-doe}{(Doe et al., 2011}}
\label{tbl:complexTable}
\centering
\begin{tblr}{
...
}
\end{table}

Table [@tbl:complexTable] shows...

With tablenos I am usually able to reference the paper with the Table: Some complex table [@doe] and when converting to pdf, the @doe reference is listed in the bibliography chapter. However since the reference is inside the latex block, it doesn't show in the bibliography chapter. How do I solve this?

2
  • 1
    In LaTeX part of a markdown you can use only Latex commands. Insert anywhere in the markdown part [@doe] and check how it is exported to LaTeX exactly (e.g., some like \autocite{doe}, but it depends on what citation method are you using.) This this is the code that you must use inside the \caption{}.
    – Fran
    May 26, 2023 at 19:04
  • @Fran Thank you for your response. The Late output of [@doe] is in fact \protect\hyperlink{ref-doe}{(Doe et al., 2011}}, however putting it there with the \hyperlink...` does not make it appear in the Bibliography chapter. Any idea how to solve this?
    – thehayro
    May 26, 2023 at 19:25

1 Answer 1

2

mwe


---
format: pdf
link-citations: true
references:
- type: article-journal
  id: doe
  author:
  - family: Doe
    given: D. D.
  issued:
    year: 2011 
  title: 'Very foo and too munch foo'
  container-title: Journal of Foo
  volume: 171
  issue: 2
  page: 737--778
nocite: | 
  @doe  
---

The table can be seen below...

\begin{table}[h]
\caption{Some complex table \protect\hyperlink{ref-doe}{(Doe, 2011)}}
\label{tbl-complexTable}
\centering
\begin{tabular}{|c|}\hline x\\\hline\end{tabular}   
\end{table}

<!-- A @doe markdown cite. -->

### References

::: {#refs}
:::

If you are exporting references with citeproc, the references are added as text in the LaTeX export, and in citations are just hyperlinks to items. There are not true citation commands to be processed by bibtex or biber programs.

From the markdown point of view, the LaTeX parts do not exist, and therefore if there are not any @doe in the markdown side, there are nothing to link and nothing to be referenced. In the LaTeX part you add a link to nowhere, not a command to include a cite and a reference. There are at least three ways to surpass this problem:

One could be simply add @doe or [@doe] somewhere in the markdown part. This will make the target, so the link to nowhere will work now. The only problem could be that you do not want other link except that of the caption. In the example, this "extra cite" is deactivated in a HTML comment. If you want to test it, turn the HTML comment in plain text, and remove the nocite directive, that is the second method:

Use nocite in the YAML header you cab include references that you do not what to mention in text. This will create the target without the link, but you provide it in the LaTeX code. To test it, run the example "as is".

The third way is to use natbib or biblatex citation methods. In this case, list the references and format the cite is an external business for bibtex or biber programs, and pandoc just washes his hands. You will need the references in bibtex (.bib) format, and specify the citation method, adding in the YAML header at least:

bibliography: references.bib # or  whatever.bib 
citation-method: natbib      # or biblatex (default is citeproc) 

The natbib and biblatex methods will leave @doe or [@doe] as a true LaTeX citation command (not just a hyperlink) and also some LaTeX commands at end of the document to print the references, so you cannot read the text of the references in the exported LaTeX code, but in the PDF only. That is, instead of be export the cite as \protect\hyperlink{target}{text} leave it as a true citation command, e.g., \textcite{doe} or \autocite{doe} (depending of the cite style, and the citation-method). The commands generated in each case in main markdown text is what you must translate to the table caption manually, and they will make the cite and the reference even if there are not @doe in markdown text or nocite in the header.

Note: sometimes is not clear for pandoc what is markdown and what is another markup language that should not be touched. It is always better to enclose the LaTeX part in this way:

```{=latex}

\begin{whatever}
\end{whatever} 

```

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .