emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] lisp/ox-latex.el: put labels inside example blocks


From: hugo
Subject: [PATCH] lisp/ox-latex.el: put labels inside example blocks
Date: Thu, 01 Dec 2022 23:36:04 +0000
User-agent: Roundcube Webmail/1.5.2

I exported an essay written in org mode to a LaTeX file (and then a pdf)
today. It had `example' blocks in several consequent sections, each with
a name (i.e. `#+name'). I have `org-latex-prefer-user-labels' set to t,
and used these names to refer to the examples later on.

I noticed that some of these labels were resolved wrong (i.e. printed as
the wrong number) in the resulting pdf. Examining the tex source, this
was because the labels had been printed outside (just before) the
example blocks, thus:

,---
|  \label{ex:foo}
|  \begin{example}
|     My example here
|  \end{example}
`---


In tnhese cases, sometimes LaTeX interpreted the surrounding section as
the subject of the label, and printed the number of that section when
the label was referred to.

The attached patch forces example environments to be printed thus:

,---
|  \begin{example}\label{ex:foo}
|     My example here
|  \end{example}
`---

This solves the problem.

The logic/conditions for when to print a label, and how it is generated
remain unchanged.

Hope this is helpful for someone else too!

Hugo

Attachment: 0001-lisp-ox-latex.el-put-labels-inside-example-blocks.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]