tomduck / pandoc-fignos Goto Github PK
View Code? Open in Web Editor NEWA pandoc filter for numbering figures and figure references.
License: GNU General Public License v3.0
A pandoc filter for numbering figures and figure references.
License: GNU General Public License v3.0
Something like:
![Figure 1](figures/figure_1.pdf){#fig:figure_one}
![Figure 2 - Subset of Figure @fig:figure_one](figures/figure_2.pdf){#fig:figure_two}
Leads to an error:
pandoc-citeproc: reference with no printed form
Weirdly, removing --filter pandoc-citeproc
from my call to pandoc
still results in the above error.
Hi there, I have not been able to install pandoc-fignos in Mac. I tried the command you suggest (also installed Python 3 before), and just get this:
sudo: pip: command not found
Thanks!
I am trying pandoc-fignos with pandoc-1.18 on Ubutu 12 and get the following error:
$ pandoc --filter pandoc-fignos demo.md
Traceback (most recent call last):
File "/usr/local/bin/pandoc-fignos", line 9, in <module>
load_entry_point('pandoc-fignos==0.18.1', 'console_scripts', 'pandoc-fignos')()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 337, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2279, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1989, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/local/lib/python2.7/dist-packages/pandoc_fignos.py", line 50, in <module>
import pandocxnos
File "/usr/local/lib/python2.7/dist-packages/pandocxnos/__init__.py", line 1, in <module>
from .core import *
File "/usr/local/lib/python2.7/dist-packages/pandocxnos/core.py", line 419, in <module>
_REF = re.compile(r'^((?:.*{)?[\*\+!]?)@([^:]*:[\w/-]+)(.*)?')
File "/usr/lib/python2.7/re.py", line 190, in compile
return _compile(pattern, flags)
File "/usr/lib/python2.7/re.py", line 242, in _compile
raise error, v # invalid expression
sre_constants.error: nothing to repeat
pandoc: Error running filter pandoc-fignos
Filter returned error status 1
If I don't use pandoc-fignos, the same input file completes successfully:
$ pandoc demo.md
<p>Some data are shown in fig. <span class="citation">@fig:data</span>.</p>
<div class="figure">
<img src="plot1.png" alt="Some data." id="fig:data" />
<p class="caption">Some data.</p>
</div>
The input file is as simple as it gets:
$ cat demo.md
Some data are shown in fig. @fig:data.
![Some data.](plot1.png){#fig:data}
Any hint ?
With python2 I get
$ ./create_pdf.sh SonarQube_Regeln.md
Traceback (most recent call last):
File "/home/hasufell/.local/bin/pandoc-fignos", line 11, in <module>
load_entry_point('pandoc-fignos==0.16', 'console_scripts', 'pandoc-fignos')()
File "/home/hasufell/.local/lib/python2.7/site-packages/pandoc_fignos.py", line 357, in main
detach_attrs_image], doc)
File "/home/hasufell/.local/lib/python2.7/site-packages/pandoc_fignos.py", line 355, in <lambda>
altered = functools.reduce(lambda x, action: walk(x, action, fmt, meta),
File "/home/hasufell/.local/lib/python2.7/site-packages/pandocfilters.py", line 34, in walk
array.append(walk(item, action, format, meta))
File "/home/hasufell/.local/lib/python2.7/site-packages/pandocfilters.py", line 39, in walk
obj[k] = walk(x[k], action, format, meta)
File "/home/hasufell/.local/lib/python2.7/site-packages/pandocfilters.py", line 39, in walk
obj[k] = walk(x[k], action, format, meta)
File "/home/hasufell/.local/lib/python2.7/site-packages/pandocfilters.py", line 39, in walk
obj[k] = walk(x[k], action, format, meta)
File "/home/hasufell/.local/lib/python2.7/site-packages/pandocfilters.py", line 25, in walk
res = action(item['t'], item['c'], format, meta)
KeyError: 'c'
pandoc: Error running filter pandoc-fignos
Filter returned error status 1
With python3:
$ ./create_pdf.sh SonarQube_Regeln.md
pandoc: Error running filter pandoc-fignos
fd:4: hPutBuf: resource vanished (Broken pipe)
The script I run is:
#!/bin/sh
die() {
echo "$1"
exit 1
}
[[ -z $1 ]] && die "missing arguments, usage: create_pdf.sh <input-file> [output-file]"
input="${1}"
output="${2:-${input%.*}.pdf}"
pandoc=${pandoc:-pandoc}
${pandoc} \
-t latex \
--template=default.latex \
--toc \
-f markdown+yaml_metadata_block+tex_math_dollars \
--filter pandoc-fignos \
-o ${output} \
${input}
I'm getting an error trying to install this on Ubuntu 16.04 with Python 3.5 and latest pip
.
pip3 install --upgrade --pre pandoc-fignos
Collecting pandoc-fignos
Downloading pandoc-fignos-1.0.0rc1.tar.gz
Collecting pandoc-xnos>=0.11 (from pandoc-fignos)
Downloading pandoc-xnos-0.11.tar.gz
Collecting pandocfilters (from pandoc-fignos)
Downloading pandocfilters-1.4.2.tar.gz
Collecting pandoc-attributes (from pandoc-fignos)
Downloading pandoc-attributes-0.1.7.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-qi1xad7m/pandoc-attributes/setup.py", line 5, in <module>
long_description = pypandoc.convert('README.md', 'rst')
File "/home/werner/.local/lib/python3.5/site-packages/pypandoc/__init__.py", line 66, in convert
raise RuntimeError("Format missing, but need one (identified source as text as no "
RuntimeError: Format missing, but need one (identified source as text as no file with that name was found).
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-qi1xad7m/pandoc-attributes/
Any idea what might cause this?
I get the error pandoc: Unknown extension: fignos
when trying to use this on Windows 10. I installed successfully with pip:
> pip show pandoc-fignos
Name: pandoc-fignos
Version: 0.20
Summary: Figure number filter for pandoc
Home-page: https://github.com/tomduck/pandoc-fignos
Author: Thomas J. Duck
Author-email: [email protected]
License: GPL
Location: c:\python27\lib\site-packages
Requires: pandoc-xnos, pandocfilters, pandoc-attributes
At the same time, the pandoc-eqnos extension, installed the same way, is working just fine.
"Links are not constructed -- just the figure numbers."
Do you have any plans to implement link creation?
Edit: I should mention that this of course works great for TeX as is. But I would love to see it work with HTML outputs as well.
I've tried to use this markdown-paper
repo. I came across this issue with the figure numbers.
Can you advise on what may be causing the error?
Hi!
Great package 👍 Why not release it to pypi?
When referencing a figure in the text, fignos produces only the figure number, without "fig" or "figure" label. Would it be possible to make its behaviour similar to pandoc-citeproc?
For example:
Figure insertion:
![My great chart with data.](fig/chart.png){#fig:chart}
Figure reference:
Lorem ipsum ({@fig:chart}) dolor sit amet
Result:
Lorem ipsum (1.1) dolor sit amet
And I mean this behaviour:
Figure reference:
Lorem ipsum ({@fig:chart}) dolor sit amet
Result:
Lorem ipsum (Figure 1.1) dolor sit amet
Figure reference:
Lorem ipsum ({-@fig:chart}) dolor sit amet
Result:
Lorem ipsum (1.1) dolor sit amet
It would also be nice to have the same behaviour in tablenos and eqnos :)
Dear Tom,
After an update the output is broken on both mac and ubuntu.
air-di-davide:~ davide$ pip show pandoc-fignos
---
Metadata-Version: 2.0
Name: pandoc-fignos
Version: 0.12
Summary: Figure number filter for pandoc
Home-page: https://github.com/tomduck/pandoc-fignos
Author: Thomas J. Duck
Author-email: [email protected]
Installer: pip
License: GPL
Location: /usr/local/lib/python2.7/site-packages
Requires: psutil, pandocfilters, pandoc-attributes
Classifiers:
Development Status :: 4 - Beta
Intended Audience :: End Users/Desktop
Environment :: Console
License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Programming Language :: Python
Entry-points:
[console_scripts]
pandoc-fignos = pandoc_fignos:main
air-di-davide:~ davide$
attached a few exports
Thanks a lot for the effort on this! This is about the last tool I need to be able to confine workflow to Rstudio and markdown. I am trying to use pandoc-fignos and the citeproc functionality in the same document. It seems the two are not behaving well together. I have added the citeproc info into the header of the demo.md and converted to .Rmd as seen below and added the .bib and .csl files to the demo directory. The demo.Rmd compiles the fig refs correctly without the csl and bibliography entry but not when they are used. Any thoughts?
Thanks,
---
output:
word_document:
pandoc_args:
- --filter
- pandoc-word-newpage
- --filter
- pandoc-fignos
html_document:
pandoc_args:
- --filter
- pandoc-word-newpage
- --filter
- pandoc-fignos
csl: environmental-toxicology-and-chemistry.csl
bibliography: HAB.bib
---
Today's data are shown in Fig. @fig:today, and yesterday's data are shown in Fig. @fig:yesterday.
![Today's $y=mx+b$ data.](img/today.png) {#fig:today}
![Yesterday's $y=mx+b$ data.](img/yesterday.png) {#fig:yesterday}
Earlier data are shown in Fig. @fig:earlier. Fig. {@fig:earlier}a is for two days ago and Fig. {@fig:earlier}b is for three days ago.
![Data from a) two days ago, and b) three days ago.](img/earlier.png) {#fig:earlier .wideimg}
Figures {@fig:today}--{@fig:earlier} (@fig:today,@fig:yesterday,@fig:earlier) reveal an increasing slope with time.
Hi, @tomduck. Can I customize the counter style of figures and figure references? A counter-style
variable could be used to set the style:
counter-style: Roman
Styles could be:
arabic
-> 1, 2, 3, ...
alph
-> a, b, c, ...
Alph
-> A, B, C, ...
roman
-> i, ii, iii, ...
Roman
-> I, II, III, ...
Thank you.
Pandoc 2.2.2.1, Python 3.6.6 on Windows 10.
I'm receiving the following error:
pandoc -f markdown-raw_tex+tex_math_single_backslash+grid_tables+pipe_tables+fancy_lists+smart+line_blocks+fenced_code_attributes -t html --mathjax --filter=pandoc-fignos --filter=pandoc-tablenos --filter=pandoc-eqnos --filter=pandoc-citeproc --bibliography=c:\users\deni\documents\archeo\library.bib --csl=c:\Users\deni\zotero\archeo\styles\journal-of-archaeological-science.csl --metadata=reference-section-title:Literatura --metadata=link-citations:true --metadata=lang:pl_PL --metadata=subparagraph:yes --metadata=fignos-caption-name:Ryc. --metadata=fignos-plus-name:ryc. --metadata=fignos-star-name:rycina --metadata=eqnos-plus-name:wz. --metadata=eqnos-star-name:wzór --metadata=xnos-cleveref:On --metadata=tablenos-caption-name:Tabela --metadata=tablenos-plus-name:tab. --metadata=tablenos-star-name:Tabela --metadata=xnos-number-sections:Off --metadata=xnos-cleveref-fake:On test.md
Traceback (most recent call last):
File "c:\program files\python36\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\program files\python36\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Program Files\Python36\Scripts\pandoc-fignos.exe\__main__.py", line 9, in <module>
File "c:\program files\python36\lib\site-packages\pandoc_fignos.py", line 415, in main
process(meta)
File "c:\program files\python36\lib\site-packages\pandoc_fignos.py", line 354, in process
assert use_cleveref_default in [True, False]
AssertionError
Error running filter pandoc-fignos:
Filter returned error status 1
Is it possible to use the same approach for table references?
Thanks
Joel
I get a similar error while using pandoc-tablenos. Pandoc was installed using homebrew, and pandoc-tablenos and pandoc-fignos using pip3. Is that a problem?
Traceback (most recent call last):
File "/usr/local/bin/pandoc-fignos", line 11, in
sys.exit(main())
File "/usr/local/lib/python3.5/site-packages/pandoc_fignos.py", line 377, in main
altered)
File "/usr/local/lib/python3.5/site-packages/pandoc_fignos.py", line 375, in
altered = functools.reduce(lambda x, action: walk(x, action, fmt, meta),
File "/usr/local/lib/python3.5/site-packages/pandocfilters.py", line 111, in walk
item['c'] if 'c' in item else None, format, meta)
File "/usr/local/lib/python3.5/site-packages/pandocxnos/core.py", line 615, in process_refs
_process_refs(value, labels)
File "/usr/local/lib/python3.5/site-packages/pandocxnos/core.py", line 119, in wrapper
ret = func(*args, **kwargs)
File "/usr/local/lib/python3.5/site-packages/pandocxnos/core.py", line 570, in _process_refs
_get_label(v['t'], v['c']) in labels:
TypeError: unhashable type: 'list'
pandoc: Error running filter pandoc-fignos
Filter returned error status
I'm currently running pandoc from nightly builds, which means I am running pandoc 2.0:
$ pandoc --version
pandoc 2.0
Compiled with pandoc-types 1.17.0.5, texmath 0.9.4.1, skylighting 0.3.3
When I attempt to use pandoc-fignos I get a version-related error message:
$ echo 'test' | pandoc --filter pandoc-fignos -t html5
Traceback (most recent call last):
File "/usr/local/bin/pandoc-fignos", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/pandoc_fignos.py", line 379, in main
PANDOCVERSION = pandocxnos.init(args.pandocversion, doc)
File "/usr/local/lib/python2.7/dist-packages/pandocxnos/core.py", line 165, in init
raise RuntimeError(msg)
RuntimeError: Cannot understand pandocversion=2.0
Error running filter pandoc-fignos:
Filter returned error status 1
The regular expression for valid pandoc versions in in line 153 of /usr/local/lib/python2.7/dist-packages/pandocxnos/core.py:
pattern = re.compile(r'^1\.[0-9]+(?:\.[0-9]+)?(?:\.[0-9]+)?$')
This matches the current debian/testing version of pandoc, 1.19.2.1, which runs with pandoc-fignos without any problem.
If I alter line 153 to also match version 2.0:
pattern = re.compile(r'^[1-2]\.[0-9]+(?:\.[0-9]+)?(?:\.[0-9]+)?$')
then pandoc version 2.0 runs just fine with the pandoc-fignos filter.
Pandoc 2 supports image parameters to be passed as:
![Caption](blah.png "Alt"){width=50%}
![Caption](blah.png "Alt"){width=50%}{#fig:iBreak}
![Caption](blah.png "Alt"){width=50%, #fig:iBreakToo}
![Caption](blah.png "Alt"){#fig:iWork}
Apart from the last one the middle two break..
When using option --filter pandoc-fignos, the encoding of utf-8 file gets broken (the national characters are messed).
Below is sample code of source markdown file:
title: Tytuł
author: Dariusz Bobak
date: 2015
csl: c:\Users\deni\zotero\archeo\styles\harvard-polish-archaeology.csl
bibliography: c:\users\deni\documents\archeo\library.bib
...
Here you can see problems with polish national characters: zażółć gęślą jaźń
Lorem ipsum dolor sit amet, „consectetur adipiscing «elit». Maecenas at nisi ut sem imperdiet” malesuada. Sed sit amet dolor in ligula commodo accumsan nec et justo. Nunc et velit id libero venenatis vehicula. Pellentesque malesuada bibendum fringilla. Nunc pharetra ut metus (@fig:wykres) vitae semper (\autoref{fig:wykres}). Proin interdum, risus malesuada luctus fermentum, erat arcu tempus tellus, sed dictum quam magna sed quam. Vivamus accumsan id lectus a hendrerit. Etiam nibh turpis, molestie eget dapibus [@bisson_nineteenth_2000] ac, vestibulum nec risus.
Donec elementum dolor [@adams_bukk_2009] urna, in rhoncus sapien eleifend vitae. Donec dignissim lacus at tellus convallis, sit amet consectetur metus tristique. Donec nec odio ultrices, varius dui sit amet, sodales mi. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Praesent libero enim, bibendum eu odio imperdiet, finibus pharetra felis. Proin ut blandit est, in accumsan odio. Sed dolor quam, varius non massa vitae, volutpat maximus erat. Etiam lacinia vulputate est a sodales. Aenean nec volutpat leo. Nullam scelerisque turpis eget suscipit varius. Donec mi tortor, sollicitudin sed ligula id, hendrerit imperdiet lectus. Quisque ac tortor quis ligula imperdiet suscipit a sit amet sem. Aliquam erat volutpat.
Sed pretium sit amet magna eu tempor. Ut sagittis est et turpis fringilla, a ultrices ex lacinia. Vestibulum leo est, lacinia at egestas a, dignissim maximus velit. Integer nisl neque, fermentum eget congue ac, pulvinar a mauris. Praesent dolor nisi, semper non tortor eu, lobortis mattis nibh. Maecenas rhoncus lorem vel dapibus semper. Praesent vel dolor non velit aliquam scelerisque. Cras quis tincidunt lorem, ac consectetur sapien. Aliquam euismod justo sed leo fringilla pellentesque. Nunc accumsan ut lorem a aliquet.
Hi, @tomduck. Can I reference multiple figures with pandoc-fignos
? I would like to use the {@fig:}
command with multiple figure labels separated by commas:
{+@fig:imgA,imgB}
-> figs. 1 and 2
{+@fig:imgA,imgB,imgC}
-> figs. 1--3
If this feature is added, the fignos-plus-name
and fignos-star-name
variables may need singular and plural forms:
fignos-plus-name:
- "fig."
- "figs."
fignos-star-name:
- "Figure"
- "Figures"
Thanks.
As a note, the output is not getting parsed for me in the filter correctly when I have a paragraph using a clever reference with the asterisk if that same paragraph later contains an asterisk for emphasis like *emphasis*
. The temporary solution/fix is to change the emphasis to use underscores: _emphasis_
. It also fails if you try to use this referencing more than once in a single paragraph (of which the only solution is to form a new paragraph... not ideal).
Thanks for the awesome filter!
hi
would it be difficult to implement clickable references in the docx format?
i assume this is not implemented or is it a bug (not clickable references)?
thanks!
It would be nice to have a syntax that places the figure number but does not create a hyperlink. For example, maybe define a new prefix like {^@fig::foo}
. In my documents, when I add a caption to the figure, I'd prefer it not to pickup link formatting since the figure is immediately next to the caption so the link is unnecessary. I don't have an opinion on an appropriate prefix, I just picked caret as an example. Thank you!
The above error with pandoc-fignos was reported at greenelab/deep-review:
The problem: There is an API incompatibility between pandoc-fignos 1.0.0 and pandoc-xnos 0.15 (the library for the pandoc-xnos/eqnos/tablenos filters).
The solution: Upgrade to the most recent version of pandoc-fignos.
I would like to prevent such errors from occurring in the future. One way forward is to move pandoc-xnos to MAJOR.MINOR.PATCH versioning and require a particular MAJOR.MINOR version for a given pandoc-fignos release. The MINOR number would be incremented for API changes.
Feedback is welcome.
Hi,
I get the following error with Pandoc v1.18
Traceback (most recent call last):
File "/Users/$USER/anaconda/envs/paper-env/bin/pandoc-fignos", line 11, in <module>
sys.exit(main())
File "/Users/$USER/anaconda/envs/paper-env/lib/python2.7/site-packages/pandoc_fignos.py", line 353, in main
meta = doc[0]['unMeta']
KeyError: 0
pandoc: Error running filter pandoc-fignos
Filter returned error status 1
make: *** [ieeetex] Error 83
I believe the filter API has changed in the new version of Pandoc
I'm writing my thesis in markdown, now using fignos, and its great, thanks so much!
I've made a small hack on the code - not really a git user, so sorry, I would have issued a pull request, I'll try to work that out next time.
What I have done is added xnos-number-offset: its basically a prefix or starting offset for the section numbering, it works great for writing chapters in separate documents. Say I want all chapter 6 figures to start with 6.X.X. Or I want all the figures in Appendix 1 to start with A1.
---
fignos-cleveref: On
fignos-plus-name: Figure
fignos-caption-name: Figure
xnos-number-offset: 6
xnos-number-sections: On
...
in
def process(meta)
. . . . .
global numberoffset
. . . . .
if 'xnos-number-offset' in meta and meta['xnos-number-offset']['c']:
tmp = get_meta(meta, 'xnos-number-offset')
numberoffset = tmp
and in
def process_figures
. . . . .
global numberoffset
. . . . .
# For html, hard-code in the section numbers as tags
kvs = PandocAttributes(attrs, 'pandoc').kvs
if numbersections and fmt in ['html', 'html5'] and not 'tag' in kvs:
if numberoffset:
cursec = numberoffset
else:
if kvs['secno'] != cursec:
cursec = kvs['secno']
Nreferences = 1
kvs['tag'] = cursec + '.' + str(Nreferences)
Nreferences += 1
I've only performed a quick hack, but the idea could be a useful addition if implemented properly
Hi, thanks for the great filter. But I encountered an issue while using it.
Markdown:
[*Hello*](http://hello.com) world
Run with pandoc-fignos (0.7.3) and pandoc (1.16.0.2)
pandoc test.md --filter pandoc-fignos
Gives me an error:
Traceback (most recent call last):
File "python/bin/pandoc-fignos", line 9, in <module>
load_entry_point('pandoc-fignos==0.7.3', 'console_scripts', 'pandoc-fignos')()
File "python/lib/python3.5/site-packages/pandoc_fignos.py", line 290, in main
doc)
File "python/lib/python3.5/site-packages/pandoc_fignos.py", line 288, in <lambda>
altered = functools.reduce(lambda x, action: walk(x, action, fmt, meta),
File "python/lib/python3.5/site-packages/pandocfilters.py", line 34, in walk
array.append(walk(item, action, format, meta))
File "python/lib/python3.5/site-packages/pandocfilters.py", line 25, in walk
res = action(item['t'], item['c'], format, meta)
File "python/lib/python3.5/site-packages/pandoc_fignos.py", line 207, in preprocess
newvalue = repair_broken_refs(value)
File "python/lib/python3.5/site-packages/pandoc_fignos.py", line 158, in repair_broken_refs
value[i+1]['t'], value[i+1]['c']):
File "python/lib/python3.5/site-packages/pandoc_fignos.py", line 140, in is_broken_ref
return key1 == 'Link' and value1[1][0]['c'].endswith('{@eq') \
AttributeError: 'list' object has no attribute 'endswith'
pandoc: Error running filter pandoc-fignos
Filter returned error status 1
Any idea on this?
I prefer to see captions as titles and descriptions of figures and as such it makes sense to place them on top of figures rather than below. I've also come across academic journals that have taken this approach. Is there currently a way of doing this in pandoc? If not, could this feature be added?
Implementing a similar syntax to tablenos would achieve this.
Figure: Caption. {#fig:id}
According to the pandoc-fignos github page label ids can contain "letters, numbers, dashes, slashes and underscores." If I include a slash ('/'), however, pandoc gives me the error:
$ pandoc --filter pandoc-fignos -t html eq-slash.md
Error running filter pandoc-fignos:
Error in $.blocks[1].c[0].c[0]: cannot unpack array of length 7 into a tuple of length 3
Test file eq-slash.md
:
See figure @fig:my/image.
![My image](image.jpg "My image"){#fig:my/image}
Pandoc version: 2.0.5 (Compiled with pandoc-types 1.17.3, texmath 0.10, skylighting 0.5).
Pandoc-fignos version: 0.21.1.
Removing the slash from the figure ids stops the error occurring and pandoc generates correct output successfully.
Both pandoc-eqnos and pandoc-tablenos are able to successfully handle equation and table ids with slashes; this problem is occurring only with pandoc-fignos.
I started using fignos a couple of days ago. Very useful, the filter is greatly appreciated.
I noted an inconsistent behavior leading to "reference fig:b03 not found" warnings. Some cases where I observed this: (note that my text is longer which may be causing the behavior?)
(from md text)
ksk asjas asdjasj (figs. @fig:b03 & @fig:b04).
![ifka sims maia](./res/monos-b-03.png){ width=697px #fig:b03 }
![af sef ef ](.\res/monos-b-04.png){ width=697px #fig:b04 }
in this case it finds fig b04 but not b03.
if I remove the space between figs. and the reference, turning it into
(figs@fig:b03 & @fig:b04).
then it finds both. It seems either as the preceding character affects the readout of the reference, or as if the preceding character makes the label to be parsed by citeproc instead of fignos, since the error message looks like:
pandoc-citeproc: reference fig:b01 not found
perhaps there is a problem with the pattern which matches and consume the tags. I personally thing that the recognition of a fig. should not be affected by the preceding token.
this is the pandoc command:
pandoc ./text.md -s -o ./text.html --filter pandoc-fignos --filter pandoc-citeproc --bibliography="./sources.yaml"
Hi @tomduck -- thanks so much for contributing these filters to the community; I use your *nos filters for academic writing all the time!
It currently appears to be impossible to use an {@fig:my_fig}
reference inside the caption of a tracked figure to reference another one (or itself?). I can imagine why this kind of recursion would be a pain to support, but I am surprisingly often missing this functionality. How hard would it be to implement?
Thanks for the great functionality. I've been using this with pandoc 1.15.2, then just started using the current pandoc 1.16 build (build from source) and pandoc-fignos stopped working. I went to the 1.16 build since it has the new figure size specification capability. I'm wondering if this broke the filter, it uses a similar id syntax.
Cheers
Greg B.
By "subfigures", I mean multiple figures in the same line. And support caption for the whole figure and for subfigures, and references. Basically, it's what pandoc-crossref does, but I prefer using pandoc-fignos.
Thanks.
The following code causes a crash in pandoc.
---
fignos-cleveref: On
...
![A simple figure.](plot.png){#fig:simple}
Here is the session:
$ pandoc-1.17.2 demo.md --filter pandoc-fignos -o out/demo.pdf
pandoc-1.17.2: Error in $[2]: expected [a], encountered Object
CallStack (from HasCallStack):
error, called at pandoc.hs:153:46 in main:Main
If a sentence is put before the figure then everything is fine.
Hi,
Currently fignos transform the ![Some data.](img/plot1.png){#fig:data}
to something like Figure 2.1
.
However, we are now working on a Chinese version of our book, in which we prefer a localized label for word "Figure". e.g, in Chinese, it should be "图 2.1".
I had a look at related code, and it seems this is hard coded. But I am not a Pythoner at all so there might be a chance I missed something.
Is there a way now to specify the figure label to other text instead of "Figure"?
Thanks!
After updating my Python environment, the plugin simply stopped working (does not replace the tags at all). No error or warning is issued. Tablenos still seems to work properly.
Info:
Python 2.7.11
pandoc 1.16.0.2
pandocfilters 1.3.0
pandoc-attributes 0.1.7
pandoc-fignos 0.7.6
EDIT: I'm on OS X & pandoc is installed via homebrew
I recently updated to pandoc 1.17.2 & pandoc-fignos master and notice that figures with spaces in their filenames are now broken.
The following markdown:
![(left) _Schotter_ Georg Nees 1969 (right) _Olympiad_ Lillian Schwartz 1971](figures/collaboration/Schotter and Olympiad.png){#fig:Schotter-Olympiad}
is generated into html:
<figure>
<img src="figures/collaboration/Schotter" alt="(left) Schotter Georg Nees 1969 (right) Olympiad Lillian Schwartz 1971" id="fig:Schotter-Olympiad" /><figcaption>(left) <em>Schotter</em> Georg Nees 1969 (right) <em>Olympiad</em> Lillian Schwartz 1971</figcaption>
</figure>
and generating a pdf leads to errors:
pandoc: Could not find image `figures/collaboration/Schotter', skipping...
Clearly the spaces are currently not propagating through the filter. This was working fine a year ago.
As a test, I removed --filter pandoc-fignos
from my pandoc build line and the images are linked correctly.
it works when code is like below:
{@fig:1}
![Number one.](img/fig-1.png){#fig:1 =}
However,in some condition, I need set the number italic or bold,
then the code failed,
the code is like below:
**{@fig:1}**
![Number one.](img/fig-1.png){#fig:1 =}
any solution?
Hi, @tomduck. Could the pandoc-fignos
, pandoc-eqnos
, and pandoc-tablenos
approaches be used to reference source code listings?
Thanks.
I hadn't used this for about a year, so I updated it (using pip on a Mac) after I updated pandoc. So now I have pandoc 2.1.3 and pandoc-fignos 1.2.0. I also run it with citeproc but I'm careful to have fignos first. It all worked a year or so ago, but now it doesn't seem to process anything.
Here's my command line:
pandoc /Users/adam/Dropbox/projects/papers2018/selfTracking/draft.md -o third_draft.pdf --filter pandoc-fignos --filter pandoc-citeproc --csl /Users/adam/Dropbox/pandocStuff/styles-master/apa.csl --include-in-header /Users/adam/Dropbox/pandocStuff/titlesec.tex --include-in-header /Users/adam/Dropbox/pandocStuff/figsfloat.tex --template /Users/adam/Dropbox/pandocStuff/mytemplate.tex --pdf-engine=xelatex --toc
And this is the markdown:
#### Stress over time
![Time all measures][image-1]{#fig:technicalprocess}
Figure {@fig:technicalprocess} shows
And here's how the pdf turns out:
Citeproc tries to process it and complains there's no reference.
I've tried uninstalling - it complains about fignos being missing then so I know it's being picked up by pandoc - and reinstalling. I've uninstalled and re-installed pandoc, too. I've run the command without citeproc and it doesn't do anything then, either. Is there something I can do to find out what's going on? I've tried it with files that definitely worked before I updated it!
Hi Tom, long time user of Fignos and Eqnos. I was trying to upgrade on Windows with Python 2.7.12 and failed. The error message included:
File "setup.py", line 46, in run
super(custom_install, self).run()
TypeError: super() argument 1 must be type, not classobj
I then hacked the setup.py
file as follows (only portions with change showed):
class custom_install(install, object): # Added object
"""Ensures setuptools uses custom install_scripts."""
def run(self):
super(custom_install, self).run() # Added arguments to super
# Custom install_scripts command class for setup()
class install_scripts_quoted_shebang(install_scripts, object): # added object
"""Ensure there are quotes around shebang paths with spaces."""
def write_script(self, script_name, contents, mode="t", *ignored):
shebang = str(contents.splitlines()[0])
if shebang.startswith('#!') and ' ' in shebang[2:].strip() \
and '"' not in shebang:
quoted_shebang = '#!"%s"' % shebang[2:].strip()
contents = contents.replace(shebang, quoted_shebang)
super(install_scripts_quoted_shebang, self).write_script(script_name, contents, mode, *ignored)
# Added arguments to super above
After that I was able to complete the install with python setup.py install
. Saw this problem with eqnos too. Don't know if this just my environment or a general issues.
Thanks
Greg B.
Hello,
I tried to use the 0.8 release in my Windows 10 installation, but I ran into a problem.
My system:
File test.md contained:
#Heading
Test text.
Command I used:
pandoc.exe --filter=pandoc-fignos.exe -t latex -o test.tex test.md
No output in the command line. The process hung indefinitely. I forcefully killed the processes using another Command Line window:
taskkill /F /IM pandoc-fignos.exe
taskkill /F /IM python.exe
I had to repeat those commands many times, until they managed to kill tens of processes that were open and quickly eating up all my memory.
After the processes were killed, the original command line showed the error below, many times:
Traceback (most recent call last):
File "C:\Python27\Scripts\pandoc-fignos-script.py", line 9, in <module>
load_entry_point('pandoc-fignos==0.8', 'console_scripts', 'pandoc-fignos')()
File "C:\Python27\lib\site-packages\pkg_resources\__init__.py", line 558, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "C:\Python27\lib\site-packages\pkg_resources\__init__.py", line 2682, in load_entry_point
return ep.load()
File "C:\Python27\lib\site-packages\pkg_resources\__init__.py", line 2355, in load
return self.resolve()
File "C:\Python27\lib\site-packages\pkg_resources\__init__.py", line 2361, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "C:\Python27\lib\site-packages\pandoc_fignos.py", line 57, in <module>
output = subprocess.check_output([command, '-v'])
File "C:\Python27\lib\subprocess.py", line 573, in check_output
raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['C:\\Python27\\Scripts\\pandoc-fignos.exe', '-v']' returned non-zero exit status 1
pandoc.exe: Error running filter pandoc-fignos.exe
Filter returned error status 1
Reverting back to pandoc-fignos 0.7.6 seemed to have fixed it.
Hope that is useful. Cheers!
If there are two figures on one line (or one two lines, with no blank in between), then figure referencing does not work. e.g.:
![some figure](path/to/image1.png}{#fig:one}
![another fig](path/to/image2.png}{#fig:two}
These figures will not be referenced. Not sure if this is intended behaviour, but if it is, maybe a note in the troubleshooting section? I just wasted a couple of hours trying to figure it out..
... does not work for me:
Markdown input:
Some text here
![Caption here](legenda.png) {#fig:legend}
Referencing figure 1a:
1. No braces @fig:legend a
2. with braces {@fig:legend}a.
Processed with
/usr/bin/pandoc +RTS -K512m -RTS test.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output test.html --smart --email-obfuscation none --filter pandoc-fignos --standalone --section-divs --table-of-contents --toc-depth 3 --template /home/mbojan/R/library/3.2/rmarkdown/rmd/h/default.html --number-sections --variable 'theme:bootstrap' --include-in-header /tmp/RtmpkT19BC/rmarkdown-str496b1622d1ac.html --no-highlight --variable highlightjs=test_files/highlight
creates HTML output (only relevant part):
<p>Some text here</p>
<a name="fig:legend"></a>
<div class="figure">
<img src="legenda.png" alt="Figure 1. Caption here" />
<p class="caption">Figure 1. Caption here</p>
</div>
<p>Referencing figure 1a:</p>
<ol style="list-style-type: decimal">
<li>No braces <a href="#fig:legend">1</a> a</li>
<li>with braces <a href="mailto:{@fig">{@fig</a>:legend}a.</li>
</ol>
As you can see the reference in item 2 is interpreted as an email address. If I switch off the autolink_bare_uris
extension (not shown) the link is correctly produced, but the curly braces are not removed (as advertised in your README).
My goal is to have references to, say, "1a" where only "1" is a link and "a" is added as a plain text. Any suggestions? Is it possible to achieve this with simple @fig:legend
reference to get "1a" without the space between 1
and a
?
Hi,
I'm using pandoc-fignos/-tablenos with the LaTeX beamer class. It seems that both filters create double tags for each caption such as
Tabelle 1: Table 1: Priority Inversion
The generated LaTeX code is
\caption{Table 1: Priority Inversion}\tabularnewline
The original markdown
Table: Priority Inversion {#tbl:ps2}
Everything's works fine with Article or Report class, it's just Beamer causing trouble.
Is this a bug?
Best,
Bid
After installing python-pip
and setuptools
as root, the following errors are shown:
pip install pandoc-fignos
Downloading/unpacking pandoc-fignos
Downloading pandoc-fignos-0.7.4.tar.gz
Running setup.py (path:/tmp/pip_build_root/pandoc-fignos/setup.py) egg_info for package pandoc-fignos
warning: no files found matching 'demos/img/today.png'
warning: no files found matching 'demos/img/yesterday.png'
warning: no files found matching 'demos/img/earlier.png'
Downloading/unpacking pandocfilters (from pandoc-fignos)
Downloading pandocfilters-1.3.0.tar.gz
Running setup.py (path:/tmp/pip_build_root/pandocfilters/setup.py) egg_info for package pandocfilters
Cleaning up...
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1235, in prepare_files
req_to_install.assert_source_matches_version()
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 465, in assert_source_matches_version
% (display_path(self.source_dir), version, self))
File "/usr/lib/python2.7/dist-packages/pip/util.py", line 70, in display_path
if path.startswith(os.getcwd() + os.path.sep):
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 31: ordinal not in range(128)
The version of Ubuntu is:
Distributor ID: Ubuntu
Description: Ubuntu 14.04.3 LTS
Release: 14.04
Codename: trusty
Not sure how to solve this.
Thanks.
Apologies for my very basic question, but I am not a coder and I don't get pandoc-fignos to work. Installing it worked fine. But the filter still does not seem to be there. After trying to use the filter employing this command in Terminal
pandoc --filter pandoc-fignos TableFigure.md -f markdown -t html -s -o TableFigure.html
I always get the error message:
pandoc: Filter pandoc-fignos not found
Any idea how I can solve this?
Best,
Julian
I'm declaring this as an issue but will not likely address it until there is demand for a fix.
There are three different labeling possibilities arising from the syntax proposed by @scaramouche1 in pandoc Issue #813.
![Caption.](fig.png){#fig:A}
![Caption.](fig.png){#fig:}
![Caption.](fig.png){}
Presently, pandoc-fignos does the right thing for html output. For PDF output, however, the case 3 figures are numbered. This is because pandoc's TeX writer only produces numbered figures.
Notes:
\caption*
command in the caption package.A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.