Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support alt text as short caption for Latex #38

Closed
hadim opened this issue Oct 12, 2015 · 12 comments
Closed

Support alt text as short caption for Latex #38

hadim opened this issue Oct 12, 2015 · 12 comments
Labels
Milestone

Comments

@hadim
Copy link
Contributor

hadim commented Oct 12, 2015

Using this patch (jgm/pandoc#2447) allow to use image alt text to convert in latex short caption. When it is used with pandoc-crossref, the short caption becomes empty...

See :

![My long caption](figure.png "SHORT CAPTION"){#fig:figure-label}

produces

\begin{figure}[htbp]
\centering
\includegraphics{figure.png}
\caption[]{\label{fig:figure-label}My long caption}
\end{figure}

Instead of :

\begin{figure}[htbp]
\centering
\includegraphics{figure.png}
\caption[SHORT CAPTION]{\label{fig:figure-label}My long caption}
\end{figure}

Any idea to fix it ?

@lierdakil
Copy link
Owner

With latex output, pandoc-crossref writes raw latex. So to fix this, one
needs to patch pandoc-crossref. I will try to take a look later this week.
12 окт. 2015 г. 14:50 пользователь "Hadrien Mary" [email protected]
написал:

Using this patch (jgm/pandoc#2447
jgm/pandoc#2447) allow to use image alt text to
convert in latex short caption. When it is used with pandoc-crossref, the
short caption becomes empty...

See :

My long caption{#fig:figure-label}

produces

\begin{figure}[htbp]\centering\includegraphics{figure.png}\caption[]{\label{fig:figure-label}My long caption}\end{figure}

Instead of :

\begin{figure}[htbp]\centering\includegraphics{figure.png}\caption[Short caption]{\label{fig:figure-label}My long caption}\end{figure}

Any idea to fix it ?


Reply to this email directly or view it on GitHub
#38.

@hadim
Copy link
Contributor Author

hadim commented Oct 12, 2015

I have the feeling there is something to do there :

RawInline (Format "tex") ("\\label{"++label++"}") : alt
but I suck too much in Haskell to be able to fix it. If you guide me I can maybe try to propose a patch.

If you think it involves too much work, I'll let you do it later this week.

@lierdakil
Copy link
Owner

At first glance line 41 should probably have "fig:" ++ snd img instead of
"fig:".
12 окт. 2015 г. 15:46 пользователь "Hadrien Mary" [email protected]
написал:

I have the feeling there is something to do there :

RawInline (Format "tex") ("\\label{"++label++"}") : alt

but I suck too much in Haskell to be able to fix it. If you guide me I can
maybe try to propose a patch.

If you think it involves a bit of work, I'll let you do it later this week.


Reply to this email directly or view it on GitHub
#38 (comment)
.

@hadim
Copy link
Contributor Author

hadim commented Oct 12, 2015

return $ Para [Image alt' (fst img, "fig:" ++ snd img)] produces the following :

\begin{figure}[htbp]
\centering
\includegraphics{figure.png}
\caption[fig:]{\label{fig:figure-label}My long caption}
\end{figure}

and return $ Para [Image alt' (fst img, "fig:" ++ "test" ++ snd img)] produces:

\begin{figure}[htbp]
\centering
\includegraphics{figure.png}
\caption[testfig:]{\label{fig:figure-label}My long caption}
\end{figure}

Seems weird to me... is haskell an inverted language ?

@lierdakil
Copy link
Owner

That's probably Pandoc, not Haskell. I don't have immediate access to
Pandoc's source ATM, so I'm not sure what's going on. Note that Pandoc's
document model uses "fig:" prefix for implicit figures, so it probably
shouldn't end up in LaTeX output...
12 окт. 2015 г. 16:15 пользователь "Hadrien Mary" [email protected]
написал:

return $ Para [Image alt' (fst img, "fig:" ++ snd img)] produces the
following :

\begin{figure}[htbp]\centering\includegraphics{figure.png}\caption[fig:]{\label{fig:figure-label}My long caption}\end{figure}

and return $ Para [Image alt' (fst img, "fig:" ++ "test" ++ snd img)]
produces:

\begin{figure}[htbp]\centering\includegraphics{figure.png}\caption[testfig:]{\label{fig:figure-label}My long caption}\end{figure}

Seems weird to me... is haskell an inverted language ?


Reply to this email directly or view it on GitHub
#38 (comment)
.

@hadim
Copy link
Contributor Author

hadim commented Oct 12, 2015

Ok. Thanks anyway. I will wait for a fix then !

@lierdakil
Copy link
Owner

Ok, so 9ef29f9 should fix this. Sorry about misleading you, I kinda forgot my own code 😅 Would be great if you could test with jgm/pandoc#2447 before I publish a release.

@hadim
Copy link
Contributor Author

hadim commented Oct 12, 2015

It works like a charm ! Thank you.

However there is a little issue and I can't tell wether it is related to pandoc-crossref or pandoc.

String inside short caption does not seems to be parsed by pandoc. For example a short caption (inside []) such as test _italic_ is not rendered with italic style but as test _italic_.

Any idea ?

@hadim
Copy link
Contributor Author

hadim commented Oct 12, 2015

After some tests, it seems related to pandoc. I will report on jgm/pandoc#2447

Thanks again @lierdakil !

@lierdakil
Copy link
Owner

Yep, that's expected. Pandoc doesn't parse image title as markdown (I think that's primarily due to "title" being an html attribute, which can't have rich formatting)

@hadim
Copy link
Contributor Author

hadim commented Oct 12, 2015

Ok I guess I can live with that :-)

I close

@hadim hadim closed this as completed Oct 12, 2015
@lierdakil lierdakil added this to the v0.1.5.5 milestone Oct 12, 2015
@lierdakil lierdakil added the bug label Oct 12, 2015
@lierdakil
Copy link
Owner

FYI, 9ef29f9 published as 0.1.5.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants