pandoc-reference-filter icon indicating copy to clipboard operation
pandoc-reference-filter copied to clipboard

Use pandoc's markdown image link text as short caption in LaTeX

Open bwhelm opened this issue 10 years ago • 4 comments

Use pandoc's markdown image link text as short caption in LaTeX

![Long caption](figure.jpg "short caption"){#fig:ref}

should produce in LaTeX:

\begin{figure}[htbp]
\centering
\includegraphics{figure.jpg}
\caption[short caption]{Long caption}
\label{fig:ref}
\end{figure}

In addition, this adds the link text to html, html5, and markdown formats.

Notes

  • I'm not sure why the math is coming out different in my versions of spec.html and spec.html5. That would seem to be unaffected by my changes here.
  • I'm not sure how to pretty print json the same way as the original, so my spec.json has too many changes (including changes to the Unicode text that happened when I prettified it). That should be fixed.
  • More important: I don't see the link text showing up in the json output when run through this filter. I'm not sure how to change that.
  • Also important: if there are no figure attributes, the link text doesn't show up in the output. I'm happy with that, but it is a limitation worth noting.

bwhelm avatar Aug 22 '15 16:08 bwhelm

R.e. math: The test references are produced by pandoc spec.md --to format --mathjax. Maybe you're missing the mathjax?

aaren avatar Aug 22 '15 19:08 aaren

R.e. json: I feed this through jq:

pandoc spec.md --to json --mathjax | jq . > spec.json

aaren avatar Aug 22 '15 19:08 aaren

I've not come across short caption before. Does it get used in figure lists?

aaren avatar Aug 22 '15 19:08 aaren

Re math: You're right. I was not using the '--mathjax' flag. Corrected now.

Re json: Thanks. I used jq's online tool to correct the output.

Re short caption: Yes, the short caption shows up in a list of figures. This is analogous to optional chapter/section titles: \section[short title]{long title} means that "short title" shows up in the table of contents (and running heads), but "long title" shows up in the main text.

bwhelm avatar Aug 23 '15 02:08 bwhelm