2

What's a good way to wrap every section in org-mode inside a LaTeX environment when exporting from org to LaTeX?

For example, say, I want to wrap each section in a minipage so that the width is smaller than a line that has been drawn over it.

For this .org file,

* Section 1
  - S1 item 1
  - S1 item 2
* Section 2
  - S2 item 1
  - S2 item 2

I want the export to produce this LaTeX:

\section{Section 1}
\hfill
\begin{minipage}{0.95\textwidth}
\begin{itemize}
\item S1 item 1
\item S1 item 2
\end{itemize}
\end{minipage}

\section{Section 2}
\hfill
\begin{minipage}{0.95\textwidth}
\begin{itemize}
\item S2 item 1
\item S2 item 2
\end{itemize}
\end{minipage}

Updated to say every section, instead of just one section.

  • Cross posted in tex.stackexchange which is something I hate to do, but I am at a loss as to where this better belongs. – user650654 Aug 30 at 18:52
  • It belongs here: it's an Org mode question, not a LaTeX question. – NickD Sep 1 at 2:49
  • 1
    Re: the revised question - you'll have to write code for that. I would suggest first a command (i.e. an interactive function) that wraps a region with the desired markup. That could be bound to a key so that you could conveniently execute it: mark a region, press key. That might be enough on its own, but it could also be used later on with something like org-map-entries to step through the headlines and apply the function to each one. – NickD Sep 3 at 14:01
3

You can use special blocks to achieve this:

* section 1
\hfill
#+attr_latex: :options {0.95\textwidth}
#+begin_minipage
- S1
- S2
#+end_minipage
  • That helps, thanks. Is there a way to wrap every section in an automated way instead of typing it out for each section? Sorry, my bad - I did not ask my question right. I have updated it with better wording. – user650654 Sep 3 at 0:58
  • Different question entirely. In this case, I would create a new latex class for org which uses your particular block instead of "section" or "subsection". – éric Sep 6 at 16:03
2

You can add arbitrary LaTeX code to your org mode file like this:

* Section 1
#+LATEX: \hfill
#+LATEX: \begin{minipage}{0.95\textwidth}
  - S1 item 1
  - S1 item 2
#+LATEX: \end{minipage}

That will produce exactly what you want (plus a label, but that's standard).

Your Answer

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

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