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

Error running filter if figure also has a label #3

Open
slochower opened this issue Aug 28, 2018 · 4 comments
Open

Error running filter if figure also has a label #3

slochower opened this issue Aug 28, 2018 · 4 comments

Comments

@slochower
Copy link

I can only get the pandoc-wrapfig filter to work if I don't also have a label on the figure. For example, this works:

![Text text text {2}.](images/motor.png)

...but this doesn't...

![Text text text {2}.](images/motor.png){#fig:motor}

In the latter case, I think the regular expression is failing:

    item['c'] if 'c' in item else None, format, meta)
  File "build/assets/pandoc-wrapfig.py", line 22, in wrapfig
    size = FLAG_PAT.match(caption[-1]['c']).group(1)
TypeError: write() argument must be str, not list
Error running filter build/assets/pandoc-wrapfig.py:

I used sys.stderr.write() to print caption[-1]['c'] and it seems to pull out the label -- ['tex', '\\label{fig:motor}'] -- instead of the caption probably because pandoc-fignos uses curly braces to define the label. A simple fix might be to only pick up the first instance of the regular expression '.*\{(\d+\.?\d?)\}'.

@scotthartley
Copy link
Owner

Unfortunately not going to have time to work on this for a little while; I've moved on to using my pandoc-chemfig package which should handle this specific problem (and some other stuff). Might clash with other filters you are using, though.

@gnpan
Copy link

gnpan commented Aug 30, 2018

An alternative is to avoid pandoc-fignos, reference the figure with \ref{motor} and use
![\label{motor} Text text text {2}](images/motor.png)

@slochower
Copy link
Author

Thanks, I'll check out chemfig, does the wwidth get passed on to non-LaTeX backends?

Also thanks @gnpan. Good thought. I expect that'll work with LaTeX but probably not with docx unless something else resolves the references first.

@scotthartley
Copy link
Owner

wwidth shouldn't do anything in non-LaTeX formats: it sets the width of the box used for wrapping in latex, but doesn't actually change the width of the image itself. It is assumed that the images are already set up to render at the correct size.

You can still use the width attribute for non-LaTeX formats though. Right now that will be ignored in LaTeX but that would be fairly straightforward to add to the filter if it was of interest. I'm afraid I'm a bit swamped right now, but I'd be happy to incorporate a pull request...

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

No branches or pull requests

3 participants