I have been working on a document that I want to export to both HTML and latex; while working on the document I noticed that using latex \label{}
and \ref{}
tags works properly for latex export, but these are shown as plain tex in the HTML export.
Similarly if I use Org links for references inside the document (for example a link to an Org header ) these are translated as links in the HTML export, but the latex export only shows a different typografy (\texttt{}
), but I don't get any hyperlink characteristic.
Is there a way to the same behavior for both exports, either latex directives to translate into html links or Org links as in-file references for the latex export?
For an example of what I'm dealing with please check the following snippet.
#+OPTIONS: H4 num:3 toc:nil \n:nil @:t ::t |:t ^:nil -_t f:t *:t <:t
#+OPTIONS: TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc
#+OPTIONS: author:t email:nil creator:nil timestamp:nil
#+LATEX_HEADER: \usepackage{geometry}
#+LATEX_HEADER: \hypersetup{colorlinks, citecolor=black, filecolor=black, linkcolor=black, urlcolor=blue}
* Section name
\label{sec:section_name} (not working properly in html export)
some text
#+LABEL: fig:image
[[img][file:image]]
some reference to figure \ref{fig:image} =link work in latex but not in html=
* other section
reference to [[* Section name][link work in html, but not latex export]],but if I use the reference \nameref{sec:section_name} will not work in html, but it will in latex export
PS: I'm aware that I may try to use pandoc, but I have never used it and I don't know if I will get the desired result, and I'd rather not use add additional tools to the toolchain.
Thanks in advance
-- Edit, Added org-mode fragment as example
[[Heading title]]
should generate an anchor link in HTML and a reference in LaTeX file. If you want to style the links, you can use#+LATEX_HEADER: \hypersetup{urlcolor=blue}
and#+LATEX_HEADER: \hypersetup{colorlinks,urlcolor=blue}
(and see ftp.ntua.gr/mirror/ctan/macros/latex/contrib/hyperref/doc/… for more options).\nameref{sec:section_name}
is absolutely not stable! E.g. in the current Org version, labels are translated to something likesec:orgheading1
by default unlessorg-latex-prefer-user-labels
is non-nil
.