1

I'm writing a large document in org that I export to PDF through latex. The latex class that I'm using (set in org-latex-classes) defines a \source command that can be used inside table and figure environments to indicate the source of that material. Something like the code below in latex

\begin{figure}[htbp]
\centering
\includegraphics[width=\textwidth]{figure.pdf}
\caption{\label{thelabel}The caption.}}
\source{Modified from~\cite{bibkey}.}
\end{figure}

In org-mode we can include the figure as (without the \source command)

#+NAME: thelabel
#+ATTR_LATEX: :width \textwidth
#+CAPTION: \caption{The caption.}
[[figure.pdf]]

My question is: How can I tell org-mode to add \source{whatever} inside the exported figure environment? Is there something I can pass to #+ATTR_LATEX: ??? to add what I need inside the environment?

Note: Unfortunately the \source command cannot be put inside the caption.


Edit: After more research I found this question on stackoverflow which is the same question as this one. Essentially, it comes down to either NickD's answer, or creating a filter, but with the filter solution there does not allow specifying what comes inside the \source command and this using :caption seems like the only way to go.

1 Answer 1

2

Try the :caption attribute in #+ATTR_LATEX: instead:

#+NAME: thelabel
#+ATTR_LATEX: :width \textwidth :caption \caption{The caption.}\source{the Source}
[[figure.pdf]]

The LaTeX file I get reads in part:

\begin{figure}[htbp]
\centering
\includegraphics[width=\textwidth]{/path/to/figure.jpg}
\caption{The caption.}\source{The Source}
\end{figure}

which should work as expected.

2
  • That's ingenious and it works. The problem with this solution is that #+NAME is ignored and thus I need to repeat the label inside \caption. Furthermore, I also want to export to HTML (although in that case I don't care about the \source) and thus I need to keep both #+ATTR_LATEX: :caption ... and #+CAPTION. If I do any change in one of them I have to remember also change the other.
    – darcamo
    Commented Nov 6, 2020 at 21:16
  • That's a different question which you should ask separately.
    – NickD
    Commented Nov 6, 2020 at 23:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.