emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: "Clément Pit--Claudel" <clement.pit@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Feature request: "Figure #:" in labels of listings
Date: Wed, 24 Aug 2016 21:51:16 +0200	[thread overview]
Message-ID: <87vayq0wuj.fsf@saiph.selenimh> (raw)
In-Reply-To: <2824f983-5494-371f-a969-bd1ea40b6810@gmail.com> ("Clément Pit--Claudel"'s message of "Mon, 22 Aug 2016 16:48:52 -0400")

Hello,

Clément Pit--Claudel <clement.pit@gmail.com> writes:

> One small difficulty is that html export uses two separate counters
> for figures and listings, while LaTeX export calls both figures, and
> uses a single counter.

This is not necessarily true. For example, when "listings" package is
used, listings and floats get a different counter.

> This makes it tricky to reference figures in a way that works with
> both HTML and LaTeX: for HTML one needs to write "Figure [[fig:a]]
> shows x, Listing [[lst:b]] shows y" (which exports into "Figure
> 1 shows x, Listing 1 shows y", while for LaTeX one needs to write
> "Figure [[fig:a]] shows x, Figure [[lst:a]] shows y" (which exports
> into "Figure 1 shows x, Figure 2 shows y"). I don't know of an easy
> way to achieve this.

You can use @@html:Listing@@@@latex:Figure@@ [[lst:a]], or with a macro

  #+macro: listing @@html:Listing@@@@latex:Figure@@

and

  {{{listing}}} [[lst:a]]

> Potential solutions:
> * Using a single counter in HTML, and calling listings "Figure"s, as in LaTeX

As stated above, this is not always correct.

> * Using two counters in LaTeX as well, though this will require changes to existing Org documents, which is not ideal.

Counters in "latex" back-end are handled on the LaTeX side, unlike to
"html".

> * Introducing an org-mode equivalent of \autoref that would insert
> (and hyperlink, which would be nice) "Figure", "Listing", "Section", …
> as appropriate based on the link's target.

I'm not sure about what you mean here, and to what export back-end it
applies.

In any case, I don't think there is a single satisfying solution. It
really depends on one's needs. I guess we could introduce a variable to
switch from one counting system to the other, if needed. Patches
welcome.


Regards,

-- 
Nicolas Goaziou

  reply	other threads:[~2016-08-24 19:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-13  3:23 Feature request: "Figure #:" in labels of listings Clément Pit--Claudel
2016-08-15 15:43 ` Nicolas Goaziou
2016-08-22 13:33   ` Clément Pit--Claudel
2016-08-22 20:27     ` Nicolas Goaziou
2016-08-22 20:48       ` Clément Pit--Claudel
2016-08-24 19:51         ` Nicolas Goaziou [this message]
2016-08-24 20:51           ` Clément Pit--Claudel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87vayq0wuj.fsf@saiph.selenimh \
    --to=mail@nicolasgoaziou.fr \
    --cc=clement.pit@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).