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

Keep subfigures on the same line in LaTeX output? #60

Closed
balachia opened this issue Mar 4, 2016 · 11 comments
Closed

Keep subfigures on the same line in LaTeX output? #60

balachia opened this issue Mar 4, 2016 · 11 comments

Comments

@balachia
Copy link

balachia commented Mar 4, 2016

Subfigures are currently written into latex with line breaks between them, so that

<div id="fig:coolFig">
![cool caption](coolfiga.png){#fig:cfa width=40%}

![cooler caption](coolfigb.png){#fig:cfb width=40%}

Cool figure!
</div>

gets written as

\begin{figure}

{\subfloat[cool caption]{\includegraphics[width=0.4\textwidth]{coolfiga.png}\label{fig:cfa}}}

{\subfloat[cooler caption]{\includegraphics[width=0.4\textwidth]{coolfigb.png}\label{fig:cfa}}}

\end{figure}

This causes subfigures to be rendered on separate lines, even if they could all fit onto a single row. Is there some way to specify whether these linebreaks should not be written? Or other ways to cause subfigures to appear in a single row?

@lierdakil
Copy link
Owner

You can coerce Pandoc to treat any image as figure. This works:

<div id="fig:coolFig">
![cool caption](coolfiga.png "fig:"){#fig:cfa width=40%}
![cooler caption](coolfigb.png "fig:"){#fig:cfb width=40%}

Cool figure!
</div>

@balachia
Copy link
Author

balachia commented Mar 4, 2016

Doesn't that break pandoc-crossref's referencing system? When I run that, I get latex output:

\hypertarget{fig:coolFig}{}
\includegraphics[width=0.4\textwidth]{coolfiga.png}
\includegraphics[width=0.4\textwidth]{coolfigb.png}

Cool figure!

Subfigure labels, and references in the text ([@fig:coolFig]) all get clobbered. Is there any way to get both pandoc-crossref to work and single-row figures without writing the tex by hand?

@lierdakil
Copy link
Owner

Did you forget to add "fig:" after image path?
5 марта 2016 г. 0:46 пользователь "Tony Vashevko" notifications@github.com
написал:

Doesn't that break pandoc-crossref's referencing system? When I run that,
I get latex output:

\hypertarget{fig:coolFig}{}\includegraphics[width=0.4\textwidth]{coolfiga.png}\includegraphics[width=0.4\textwidth]{coolfigb.png}

Cool figure!

Subfigure labels, and references in the text ([@fig:coolFig]) all get
clobbered. Is there any way to get both pandoc-crossref to work and
single-row figures without writing the tex by hand?


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

@danil-tolkachev
Copy link

I try this

<div id="fig:coolFig">
![cool caption](coolfiga.png "fig:"){#fig:cfa width=40%}
![cooler caption](coolfigb.png "fig:"){#fig:cfb width=40%}

Cool figure!
</div>

But subfigures labels hide off. Is it posible to show them?

@lierdakil
Copy link
Owner

@danil-tolkachev, what is your output format?

@danil-tolkachev
Copy link

@lierdakil, html and docx. Sorry for off topic. By labels I mean 'a' and 'b'

@lierdakil
Copy link
Owner

At the moment, there is no direct way to get multiple (sub)figures on one line with these.

You could probably hack something together with grid tables, but only master supports that at the moment (i.e. you need to build pandoc-crossref from repo)

Example:

<div id="fig:coolFig">
+---------------------------------------------------------+-----------------------------------------------------------+
|![cool caption](coolfiga.png "fig:"){#fig:cfa width=100%}|![cooler caption](coolfigb.png "fig:"){#fig:cfb width=100%}|
+---------------------------------------------------------+-----------------------------------------------------------+

Cool figure!
</div>

Not sure how that will fare with docx output though. Probably not very well, if I had to guess.

@danil-tolkachev
Copy link

@lierdakil, thank you. I'll try to build pandoc-crossref, but I'm not sure that I can do it. When is the next release?

@danil-tolkachev
Copy link

I noticed that image caption doesn't marked with tag caption (html output) for coerced subfigures. It's a bug or a feature?

@danil-tolkachev
Copy link

danil-tolkachev commented Jun 22, 2016

Move comment to #79. Sorry for mess.

@lierdakil
Copy link
Owner

Patch to avoid unsightly "fig:" hack for LaTeX output is in master. Now syntax like

<div id="fig:coolFig">
![cool caption](coolfiga.png){#fig:cfa width=40%}
![cooler caption](coolfigb.png){#fig:cfb width=40%}

![cool caption](coolfiga.png){#fig:cfx width=40%}
![cooler caption](coolfigb.png){#fig:cfy width=40%}

Cool figure!
</div>

will work as one would expect, i.e. produce two rows of subfigures side-by-side:

\begin{figure}

\subfloat[cool
caption]{\includegraphics[width=0.40000\textwidth]{coolfiga.png}\label{fig:cfa}}
\subfloat[cooler
caption]{\includegraphics[width=0.40000\textwidth]{coolfigb.png}\label{fig:cfb}}

\subfloat[cool
caption]{\includegraphics[width=0.40000\textwidth]{coolfiga.png}\label{fig:cfx}}
\subfloat[cooler
caption]{\includegraphics[width=0.40000\textwidth]{coolfigb.png}\label{fig:cfy}}

\caption{Cool figure!}

\label{fig:coolFig}

\end{figure}

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

No branches or pull requests

3 participants