markdown icon indicating copy to clipboard operation
markdown copied to clipboard

Heading labels

Open Anaphory opened this issue 5 years ago • 4 comments

Currently, \label{}s are only generated for tables and figures, it appears. With headerAttributes=true, headings can get HTML attributes including, according to the examples, of the shape {#foo} which

currently have no effect other than enabling content slicing, see the slice option.

When writing a paper with some of its content in Markdown, it would be very nice to be able to provide internal cross-references to sections. I can, obviously, use mixed mode and provide manual \label{}s, but given that the HTML attribute syntax already exists, is parsed and used for some purpose, wouldn't it make sense to use it (maybe optionally) also for generating heading labels?

Anaphory avatar May 20 '20 14:05 Anaphory

Currently, \label{}s are only generated for tables and figures, it appears.

Sorry to say that labels are currently not generated at all, not even for tables or figures.

wouldn't it make sense to use it (maybe optionally) also for generating heading labels?

It would be a welcome feature, but I currently do not have the time to implement it. In June, perhaps, or if someone else is interested in implementing the feature.

Witiko avatar May 20 '20 18:05 Witiko

Ah. I had just been searching for \label in the technical documentation and https://github.com/Witiko/markdown/blob/42853fdae267a2dc8bf0e91477086727610dae21/markdown.dtx#L16496 in a fitting context made me think that tables got labels, similarly for figures.

Anaphory avatar May 20 '20 20:05 Anaphory

What I said above was not entirely true. Figures do receive labels with the default LaTeX renderer prototypes: ![an-example](example.png "An example") can be referenced as \ref{fig:an-example}.

Tables do not receive labels: line 16,496 only applies to CSV files specified through content blocks and it does nothing useful, only redefines label tab:csv. Thanks for noticing, I removed the line in 4b516f7.

Witiko avatar May 22 '20 21:05 Witiko

pandoc-crossref is a useful project which provides additional features for cross reference (figure, table, equation and section) in Markdown. So it would be great if markdown package could support the syntax of pandoc-crossref.

TomBener avatar Nov 20 '20 11:11 TomBener

Header identifiers current produce \labels now:

\begin{markdown}[headerAttributes, relativeReferences]

We list previous work in Section <#previous-work>.

# Previous work {#previous-work}
We previously worked on the previous sections.
Now, we are hard at work on this one.

\end{markdown}

Options autoIdentifiers and gfmAutoIdentifiers will produce \labels automatically for you:

\begin{markdown}[autoIdentifiers, relativeReferences]

We list previous work in Section <#previous-work>.

# Previous work
We previously worked on the previous sections.
Now, we are hard at work on this one.

\end{markdown}

Closing this issue, please feel free to reopen it if you are unhappy with the current implementation.

Witiko avatar May 30 '24 20:05 Witiko