Preventing Org Mode from Translating Commentary as a Detailing Environment

I have a document org-mode

that I want to export as PDF. I'm using the LaTeX declaration pack to create nicely formatted code lists that look like this in org:

#+BEGIN_LaTeX
\begin{lstlisting}[language=Java]
    /** Comment comment comment
     * 
     * blah blah blah
     * 
     * @return comment
     */
    public void foo() {
        return;
    }
\end{lstlisting}
#+END_LaTeX

      

The Javadoc comment translates org as a LaTeX environment itemize

, for example:

\begin{lstlisting}[language=Java]
    /** Comment comment comment
\begin{itemize}
\item 
\item blah blah blah
\item 
\item @return comment
\end{itemize}
     */
    public void foo() {
        return;
    }
\end{lstlisting}

      

How can I prevent this and keep the Javadoc as I wrote it? If I use #+BEGIN_SRC

rather than #+BEGIN_LaTeX

, then I come back, it's a medium verbatim

, but I want to stick with lists and not verbatim

or chalk, since I've already made an attempt to put together a good set of styles for it.

+3


source to share


1 answer


What you ultimately want is a literal example . Basically, you want the code to be exported but encrypted. You must specify to org-mode

use lists (or minted) when exporting. This can be done in the .emacs file:

;; tell org to use listings with colors                                                     
(setq org-export-latex-listings t)
(add-to-list 'org-export-latex-packages-alist '("" "listings"))
(add-to-list 'org-export-latex-packages-alist '("" "color"))

      

Also, with this, you don't need to specify the package listings

in the header argument for your document. The blocks of source code will now be exported to the appropriate environment lstlistings

:

#+begin_src java                                                                
  /** Comment comment comment                                                   
   *                                                                            
   * blah blah blah                                                             
   * @return comment                                                            
   */                                                                           
  public void foo() {                                                           
    return;                                                                   
  }                                                                             
#+end_src

      



exported to LaTeX as

\lstset{language=java}
\begin{lstlisting}
/** Comment comment comment
 *
 * blah blah blah
 * @return comment
 */
public void foo() {
    return;
}
\end{lstlisting}

      

I'm not really sure why, when you use a block #+begin_latex

... #+end_latex

in your example, these things feel strange. Basically, I would like everything in the LaTeX block to be transferred as a .tex file.

+6


source







All Articles