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

Syntax for subfigure alignment #79

Closed
danil-tolkachev opened this issue Jun 27, 2016 · 2 comments
Closed

Syntax for subfigure alignment #79

danil-tolkachev opened this issue Jun 27, 2016 · 2 comments

Comments

@danil-tolkachev
Copy link

I'm using the hack with grid tables to align subfigures. It's working, but sometimes it's awkward. If I want place subfigures in the table with same column width, I have to manually add extra spaces for short columns. Moreover, when subcaption is long and/or three or more subfigures are placed in grid table, the source lines of table become very long. It would be handy if pandoc-crossref form this table itself.

For example, the following

<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>

would be equal to (I'm adding two spaces to get same column width)

<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>

And if I wanted to place subfigures in the 3x2 table, I would write

<div id="fig:coolFig">
![caption a](coolfiga.png){#fig:cfa width=100%}
![caption b](coolfigb.png){#fig:cfb width=100%}
![caption c](coolfigb.png){#fig:cfc width=100%}

![caption d](coolfigd.png){#fig:cfd width=100%}
![caption e](coolfige.png){#fig:cfe width=100%}
![caption f](coolfigf.png){#fig:cff width=100%}

Cool figure!
</div>

Of course, this feature could be optional.

@lierdakil
Copy link
Owner

I've implemented something like this in master. There are a couple caveats. You need to enable subfigGrid metadata option for this to work (boolean, default false)

Column widths will be taken from width attributes of corresponding images, e.g.

<div id="fig:coolFig">
![caption a](coolfiga.png){#fig:cfa width=30%}
![caption b](coolfigb.png){#fig:cfb width=60%}
![caption c](coolfigb.png){#fig:cfc width=10%}

![caption d](coolfigd.png){#fig:cfd}
![caption e](coolfige.png){#fig:cfe}
![caption f](coolfigf.png){#fig:cff}

Cool figure!
</div>

will produce a table with columns of 30%, 60% and 10% respectively.

Only first row of images is considered, other rows are completely ignored.

Anything except images is silently ignored. So any text, spaces, soft line breaks etc will silently disappear from output. That doesn't apply to caption paragraph, obviously.

All images will have width attribute automatically set to 100% in order to fill whole column.

Specifying width in anything but % will throw an error.

If width for some images in first row is not specified, those will span equally in the remaining space.

If width isn't specified for any image in first row, those will span equally on 99% of page width (due to Pandoc otherwise omitting width attribute for table)

Let me know if this is satisfactory, or if you run into issues.

@danil-tolkachev
Copy link
Author

Thank you very much. All works fine.

@lierdakil lierdakil modified the milestone: v0.2.2.1 Aug 9, 2016
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

2 participants