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

LaTeX: Support for Subfigure Package #3577

Closed
schrieveslaach opened this issue Apr 16, 2017 · 6 comments
Closed

LaTeX: Support for Subfigure Package #3577

schrieveslaach opened this issue Apr 16, 2017 · 6 comments

Comments

@schrieveslaach
Copy link
Contributor

Many scientific papers include subfigures. For example:

\begin{figure}[ht]
    \begin{subfigure}{0.45\textwidth}
        \includegraphics{img1.jpg}
        \caption{Catpion 1}
    \end{subfigure}
    
    \begin{subfigure}{0.45\textwidth}
        \includegraphics{img2.jpg}
        \caption{Catpion 2}
    \end{subfigure}
    \caption{Subfigure with Subfloat}
\end{figure}

Pandoc should produces two figures nested in a outer figure.

<figure>
<figure>
<img src="img1.jpg" alt="Catpion 1" /><figcaption>Catpion 1</figcaption>
</figure>
<figure>
<img src="img2.jpg" alt="Catpion 2" /><figcaption>Catpion 2</figcaption>
</figure>
<figcaption>Subfigure with Subfloat</figcaption>
</figure>
@jgm
Copy link
Owner

jgm commented Apr 16, 2017

Pandoc's internal document model doesn't currently have a dedicated block element for figures. We use the hack of treating images that are by themselves in a paragraph, with a title beginning fig:, as figures.

Going forward it would be good to have a dedicated Figure block element. See #3177.

Without better support for figures in the AST, the best we could do with subfigures would be to parse them as a sequence of figures.

@schrieveslaach
Copy link
Contributor Author

Thanks for the clarification. Currently, a sequence of figures is sufficient for my needs. I assume, that you are already working on this?

I'm trying to fix the caption problem. I think it has something to do with the setCaption and resetCaption and addImageCaption. In an imperative programming language I would use a stack to solve this. Do you have any ideas to solve this in haskell?

tarleb added a commit to tarleb/pandoc that referenced this issue Apr 17, 2017
@tarleb tarleb closed this as completed in 464db59 Apr 17, 2017
@tarleb
Copy link
Collaborator

tarleb commented Apr 17, 2017

Sorry, typo in commit.

@tarleb tarleb reopened this Apr 17, 2017
@jgm
Copy link
Owner

jgm commented Apr 23, 2017

I'm trying to fix the caption problem. I think it has something to do with the setCaption and resetCaption and addImageCaption. In an imperative programming language I would use a stack to solve this. Do you have any ideas to solve this in haskell?

@schrieveslaach What currently happens with the above example when you run the code in your PR?
Just eyeballing it, I don't see why captions would be messed up.

@schrieveslaach
Copy link
Contributor Author

schrieveslaach commented Apr 24, 2017

@jgm, The outer caption will be used twice:

<figure>
<img src="img1.jpg" alt="Subfigure with Subfloat" /><figcaption>Subfigure with Subfloat</figcaption>
</figure>
<figure>
<img src="img2.jpg" alt="Subfigure with Subfloat" /><figcaption>Subfigure with Subfloat</figcaption>
</figure>

I would expect at least following output.

<figure>
<img src="img1.jpg" alt="Subfigure with Subfloat" /><figcaption>Caption 1</figcaption>
</figure>
<figure>
<img src="img2.jpg" alt="Subfigure with Subfloat" /><figcaption>Caption 2</figcaption>
</figure>

Ideally, the third caption should be placed below:

<figure>
<img src="img1.jpg" alt="Subfigure with Subfloat" /><figcaption>Caption 1</figcaption>
</figure>
<figure>
<img src="img2.jpg" alt="Subfigure with Subfloat" /><figcaption>Caption 2</figcaption>
</figure>
<figcaption>Subfigure with Subfloat</figcaption>

@jgm jgm closed this as completed in d17f0da Apr 24, 2017
@jgm
Copy link
Owner

jgm commented Apr 24, 2017

I found a solution.

link2xt pushed a commit to link2xt/pandoc that referenced this issue Apr 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants