0

I have an org-mode document that includes source listings of two kinds: XML and text, where the XML code refers to the text file. I want to include the two source listings into the same float in the latex export document. Is that possible?

Consider the org-mode code below:

#+ATTR_LATEX: :float t :options label=Block in main XML file
#+LABEL: listing:images
#+CAPTION: The images subsection refers to a separate text file.
#+BEGIN_SRC xml
  <images>
    <file format="id,path">images/images.txt</file>
  </images>
#+END_SRC

#+ATTR_LATEX: :float t :options label=images/images.txt
#+LABEL: listing:images_text
#+CAPTION: The =images.txt= file referred to in listing \ref{listing:images}.
#+BEGIN_SRC text
# Image paths for DBAT camera calibration demo
# Format: id, path
 1, data/dbat/images/cam/P8250021.JPG
...
21, data/dbat/images/cam/P8250041.JPG
#+END_SRC

The latex export of the above example is in two floats:

\begin{listing}[htbp]
\begin{minted}[label=Block in main XML file]{xml}
<images>
  <file format="id,path">images/images.txt</file>
</images>
\end{minted}
\caption{\label{listing:images}
The images subsection refers to a separate text file.}
\end{listing}

\begin{listing}[htbp]
\begin{minted}[label=images/images.txt]{text}
# Format: id, path
 1, data/dbat/images/cam/P8250021.JPG
...
21, data/dbat/images/cam/P8250041.JPG
\end{minted}
\caption{\label{listing:images_text}
The \texttt{images.txt} file referred to in listing \ref{listing:images}.}
\end{listing}

However, I would like to have the listings appear in the same float, i.e.,

\begin{listing}[htbp]
\begin{minted}[label=Block in main XML file]{xml}
<images>
  <file format="id,path">images/images.txt</file>
</images>
\end{minted}
\begin{minted}[label=images/images.txt]{text}
# Format: id, path
 1, data/dbat/images/cam/P8250021.JPG
...
21, data/dbat/images/cam/P8250041.JPG
\end{minted}
\caption{\label{listing:images}
The images subsection refers to a separate text file.}
\end{listing}

Is there a way to get this result without having to edit the latex file?

emacs version 25.2.2, org-mode version 9.2.6.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.