Giter VIP home page Giter VIP logo

pandoc-crossref's Introduction

pandoc-crossref filter Build status

pandoc-crossref is a pandoc filter for numbering figures, equations, tables and cross-references to them.

The input file (like demo.md) can be converted into HTML, LaTeX, PDF, Markdown or other formats.

Optionally, you can use cleveref for LaTeX/PDF output, e.g. cleveref PDF, cleveref LaTeX, and listings package, e.g. listings PDF, listings LaTeX

You can also enable per-chapter numbering (as with --chapters for latex output). You need to specify -M chapters for non-LaTeX/PDF output however. Examples: HTML, Markdown, LaTeX, PDF.

This work is inspired by pandoc-fignos and pandoc-eqnos by @tomduck.

This package tries to use LaTeX labels and references if output type is LaTeX. It also tries to supplement rudimentary LaTeX configuration that should mimic metadata configuration by setting header-includes variable.

Installation

The easiest option to get pandoc-crossref on Windows, macOS, or Linux, is to download pre-built executables available at the releases page. Bear in mind that those are a product of automated build scripts, and as such, provided as-is, with zero guarantees. Feel free to open issues if those don't work though, I'll try to do what I can.

WARNING: When using pre-built executables, make sure that your pandoc version matches the version pandoc-crossref was built against, otherwise weird stuff will likely happen. Feel free to open issues if there's a new version of pandoc available, for which there are no pandoc-crossref builds.

NOTE: Linux and Windows binaries are packed with upx (not macOS though, since upx apparently has questionable interactions with Apple's x86 emulation on A1 processors). If you don't like the overhead, and don't mind 40-megabyte binaries, you can unpack those manually with upx -d pandoc-crossref. Also please notice that upx-packed binaries can break in some exotic environments, like empty chroot with no access to /proc, etc.

Also, for those feeling adventurous, the automatic builds for the latest commits are available. Latest builds can be found on the nightlies tag (despite the name, those aren't actually built nightly, but on each push instead)

If you don't trust random binaries downloaded off the Internet (which is completely reasonable), you're welcome to build from source. You have two preferred options for that: building from Hackage with cabal-install, or from repository with stack (you'll only need stack and maybe git). See below for build instructions.

If you're completely new to Haskell, the latter, i.e. building from repo with stack, is the easier option in most cases.

This repository is also a nix flake. You can use nix to get it installed.

Alternatively, you can use a version provided by a third party. At the time of writing, pandoc-crossref is provided on the following platforms (that I am aware of):

  • Arch Linux
  • NixOS or Nix package manager (via nixpkgs.haskellPackages attribute)
  • MacOS (via Homebrew)
  • FreeBSD official binary package textproc/hs-pandoc-crossref
  • Any Linux distribution (via Linuxbrew)
  • Gentoo Linux (via gentoo-haskell overlay)
  • Windows (via scoop)

Building from Hackage with cabal-install

You'll need to get GHC and cabal-install installed first. By far the easiest way to get those is via ghcup.

Describing using ghcup is out of scope for this small guide, but TL;DR is this:

ghcup install ghc
ghcup install cabal

After you got cabal-install and ghc, run:

cabal v2-update
cabal v2-install --install-method=copy pandoc-cli pandoc-crossref

This will get pandoc-crossref and pandoc executables copied to $HOME/.cabal/bin (by default, if not, check your cabal config file installdir setting -- find out where your config file is by running cabal help user-config), which you can then add to PATH or copy/move the symlinks where you want them.

Refer to cabal documentation if you need to build a particular version (TL;DR: add --constraint pandoc-crossref==<version> to the installation command)

Note: if you're using cabal to build from a repo checkout, and not from Hackage as described above, you'll need to either match the compiler version specified in ghcver in .github/workflows/haskell.yml, or remove cabal.project.freeze from the root of the repository. Otherwise, cabal will complain about version mismatch of boot packages (like base, ghc-boot-th, etc)

Building from repo with stack

First of all, get stack if you don't have it already: see the official stack documentation. Note that stack can also be installed via ghcup, and on Linux it is usually available in your package manager.

If you have git, you can now clone the repository and build:

git clone https://github.com/lierdakil/pandoc-crossref.git
cd pandoc-crossref
git checkout <commit/tag/branch>
stack install

If you don't have git, just download the sources for your preferred commit/branch/tag via the GitHub interface, and run stack install in the directory that contains stack.yaml file.

This will install pandoc-crossef executable to $HOME/.local/bin. You might also want to separately run stack install pandoc-cli in the same directory (i.e. the root of the repository, the one containing stack.yaml file)

Installing as a nix flake

TL;DR:

nix profile install github:lierdakil/pandoc-crossref

will install the latest commit from the master branch. You can also specify a commit, branch or tag, e.g.:

nix profile install github:lierdakil/pandoc-crossref/71c8c8508c222bf4110794457fdf0391b05fb9a9

You can also get the corresponding pandoc version installed via

nix profile install github:lierdakil/pandoc-crossref#pandoc

Since you will generally want both, there's an option to install both at the same time, too:

nix profile install github:lierdakil/pandoc-crossref#pandoc-with-crossref

Aside from added convenience, this guarantees pandoc and pandoc-crossref versions to be consistent across updates.

Finally, you can start a nix shell with both pandoc and pandoc-crossref using

nix develop github:lierdakil/pandoc-crossref

Warning: this uses haskell.nix infrastructure for builds (because Haskell support in Nix is borked, and has been for a long time). This means that unless you use their substituters, you'll build multiple GHC versions from source. To avoid that, add https://cache.iog.io to substituters in nix.conf and hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= to trusted-public-keys.

You can also use pandoc-crossref's binary cache by adding https://pandoc-crossref.cachix.org and pandoc-crossref.cachix.org-1:LI9ABFTkGpPCTkUTzoopVSSpb1a26RSTJNMsqVbDtPM= to substituters and trusted-public-keys respectively.

The flake includes both by default, so if you're a nix trusted user and accept these configurations during flake evaluation those will be used automatically.

Notice Fedora users

cabal-install package is not enough to build pandoc-crossref (see #132). To get a sane Haskell build environment, you need to install the haskell-platform package (dnf install haskell-platform).

While on topic, if you don't want to rebuild pandoc itself from source, make sure you have pandoc and ghc-pandoc-devel dnf packages before attempting to build pandoc-crossref.

Usage

Usage information is available at https://lierdakil.github.io/pandoc-crossref/

Projects

The following projects use this filter:

License

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

See LICENSE for details.

© 2016 Nikolay Yakimov et al

Contributors (per GPL, holders of copyright on their respective contributions):

  • Nikolay Yakimov
  • gesh
  • Raphael Das Gupta
  • Masamichi Hosoda
  • Felix Yan
  • Wlad
  • Wandmalfarbe
  • Vekhir
  • Silas Benson
  • shutingrz
  • Shaun Jackman
  • scoavoux
  • Salim B
  • Matthew Salganik
  • Jan-T. Brinkmann
  • hseg
  • Han Joosten
  • Hadrien Mary
  • Gleb Popov
  • Gabriel Nützi
  • David Arnold
  • Chris Black
  • Bart Mesuere
  • Albert

This repository includes code from https://github.com/roelvandijk/roman-numerals, covered by a different license. See licenses/LICENSE.roman-numerals for details.

How to bump pandoc version

  1. Change PANDOC_VERSION in .github/workflows/haskell.yml to the new Pandoc version.

  2. Run make update. You need at least nix, stack and cabal (i.e. cabal-install) installed and in PATH.

    If it doesn't do anything, consider nuking cabal.project.freeze, flake.lock, stack.yaml and stack.yaml.lock and trying again.

  3. Build and test.

  4. Fix broken tests.

  5. Repeat 3-4 until all tests pass.

pandoc-crossref's People

Contributors

arrowd avatar bmesuere avatar corollari avatar das-g avatar felixonmars avatar gabyx avatar hadim avatar hanjoosten avatar hseg avatar infotroph avatar jtbrinkmann avatar lierdakil avatar msalganik avatar salim-b avatar scoavoux avatar shutingrz avatar silasvb avatar sjackman avatar trueroad avatar vekhir avatar wandmalfarbe avatar wladston avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pandoc-crossref's Issues

Subfigures (with caption)

Is subfigures possible?

Something like this would be great:


![Caption for (a).](img.png) ![Caption for (b).](img2.png) {#fig:two_figs}

or


![Caption for (a).](img.png) {#fig:one}
![Caption for (b).](img2.png) {#fig:two}

Referencing directly to [@fig:one].

Request: Move space added between reference prefixes and numbers to the template

If I set up a custom template for something, for example to give a title of Figure B1, then when I reference it, pandoc-crossref adds a space after the figPrefix variable. So if I set figPrefix to "Fig. B", I will get
Fig. B 1 instead of Fig. B1

Moving the space to the template means that users have control over that space instead of it being hardcoded.

The same might be useful with titles as well, though it's less necessary with the templates.

It's probably an easy change and if I can find the spot in Refs.hs I may try to submit a pull request.

Multiple labels defined. Bugs?

pandoc: 1.16.0.2
pandoc-crossref: 0.1.6.3

When images are used in subsequent paragraphs of lists, multiple labels will be produced.

to reproduce, just save the following code as a file test.md

1.  list item1

    *   Bullet list1

        1)  inner list 1

            This paragraph will following the inner list 1.

            ![This image will not break the list](image1.png){#fig:image1}

        2)  inner list 2

$ pandoc -t latex -o test.tex --filter pandoc-crossref test.md

The test.tex shows:

\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\item
  list item1

  \begin{itemize}
  \item
    Bullet list1

    \begin{enumerate}
    \def\labelenumii{\arabic{enumii})}
    \item
      inner list 1

      This paragraph will following the inner list 1.

      \begin{figure}[htbp]
      \centering
      \includegraphics{image1.png}
      \caption{\label{fig:image1}\label{fig:image1}\label{fig:image1}\label{fig:image1}This
      image will not break the list}
      \end{figure}
    \item
      inner list 2
    \end{enumerate}
  \end{itemize}
\end{enumerate}

There are four \label.

If the image paragraph is not indented by spaces, the inner list 2 will not be generated properly.

BTW, It would be better if \label is not in the \caption field. That's the expected latex way.

\begin{figure}[htbp]
      \centering
      \includegraphics{image1.png}
      \caption{This image will not break the list}
      \label{fig:image1}
\end{figure}

With \label embedded in \caption, problems will arise if caption (of figure, table) appear in multiple places.

issue with per-chapter numbering and unnumbered chapters

I'm working on a book with a few unnumbered chapters without images as front-matter.
If I use per-chapter numbering, the pandoc-crossref chapter seems to also increment for these chapters.
Therefore, my chapter 2 figures are numbered Figure 5.1, Figure 5.2,...

Is this expected behaviour and if so, is there a workaround to manually reset the internal counter so I can make the pandoc chapter numbers and the pandoc-crossref chapter numbers match?

Separate numbering for supplemental figures/tables

For a paper with a large supplemental section, I needed to maintain two separate sets of figure and table numberings, e.g. (See @fig:fig1, @fig:fig4, @supfig:figS1) ==> "(See Figures 1, 4, and S1)". I've hacked together most of a solution for this at https://github.com/infotroph/pandoc-crossref/tree/supplemental.

This is not a pull request, because I doubt you want my code: It duplicates nearly all of the existing figure and table code, provides no way to support other supplements (equations, listings, etc) other than also duplicating their code, and the numbering is broken in LaTeX and would probably need a custom Pandoc writer to fix it. I'm only posting it here in case it can help someone else who'd otherwise be hassling you for a real fix :)

Support alt text as short caption for Latex

Using this patch (jgm/pandoc#2447) allow to use image alt text to convert in latex short caption. When it is used with pandoc-crossref, the short caption becomes empty...

See :

![My long caption](figure.png "SHORT CAPTION"){#fig:figure-label}

produces

\begin{figure}[htbp]
\centering
\includegraphics{figure.png}
\caption[]{\label{fig:figure-label}My long caption}
\end{figure}

Instead of :

\begin{figure}[htbp]
\centering
\includegraphics{figure.png}
\caption[SHORT CAPTION]{\label{fig:figure-label}My long caption}
\end{figure}

Any idea to fix it ?

Feature request: Number all equations

Hi,

Would it be possible to have a setting to number all equations by default?

I like to have all my equations numbered, although I do not necessarily reference them further in the document, and would be great if it could be done without having to introduce extra useless labels or using \begin{equation} … \end{equation}.

Thanks!

non-breaking space between prefix and number

Currently, a normal space is inserted between figPrefix, tblPrefix, eqnPrefix and its corresponding reference number. At line ends, this sometimes breaks the number to the next line wich should be avoided. Therefore, a non-breaking space should be inserted instead.

subfigures break height setting, do not support empty caption

Input md:

<div id="fig:gen">
![](../figures/AZ_VARIED_scatter.png){height=20%}

![](../figures/EL_VARIED_scatter.png){height=20%}

![](../figures/LIGHT_AZ_VARIED_scatter.png){height=20%}

Captions are great!
</div>

output tex:

\begin{figure}

{\subfloat[]{\includegraphics{../figures/AZ_VARIED_scatter.png}\label{fig:}}}

{\subfloat[]{\includegraphics{../figures/EL_VARIED_scatter.png}\label{fig:}}}

{\subfloat[]{\includegraphics{../figures/LIGHT_AZ_VARIED_scatter.png}\label{fig:}}}

    \caption{{Captions are great!}}

    \label{fig:gen}

\end{figure}

resulting pdf:

screenshot 2016-01-28 17 05 47

Subfigures not working

Here's my markdown:

<div id="fig:gen">
![](../figures/AZ_VARIED_scatter.png)

![](../figures/EL_VARIED_scatter.png)

![](../figures/LIGHT_AZ_VARIED_scatter.png)

Captions are great!
</div>

and here's the tex it renders to:

\hypertarget{fig:gen}{}
\begin{figure}[htbp]
\centering
\includegraphics{../figures/AZ_VARIED_scatter.png}
\caption{}
\end{figure}

\begin{figure}[htbp]
\centering
\includegraphics{../figures/EL_VARIED_scatter.png}
\caption{}
\end{figure}

\begin{figure}[htbp]
\centering
\includegraphics{../figures/LIGHT_AZ_VARIED_scatter.png}
\caption{}
\end{figure}

Captions are great!

I'm using up-to-date master, and I'd love to help debug.

reference to code listings

Currently I do:

\begin{lstlisting}[language=Python, caption=Caption., label=code:label]
for file in files:
    ..do stuff
\end{lstlisting}

Then I reference with \ref{code:label}. This gives me two syntaxes for referencing. It would be nice if @code:label would create \ref{code:label} regardless if pandoc-crossref finds a label named code:label in its own list of figures/equations/tables. Any ideas?

Figure labels

I have updated to the latest version but still get figure labels as

fig 1.

I have added to the yaml header

figureTitle: 'Figure'
tableTitle: 'Table'

using RStudio-knitr-pandoc writing output to word .docx

Thanks,

Joel

section reference in appendix

Does {#sec:label} works when specified after \appendix and called in the main text before \appendix with something like that @sec:label.

In my case it generates the following : Section ??

Any idea ?

label prefixes are removed (and probably make them non-unique)

If {#fig:test} and {#tbl:test} used in the same document, referencing would not work. This is more or less a cosmetic bug. But users who used Latex labels before, may expect that the label is kept in its etirety. For instance, in Latex it is valid to use \label{fig:test} and \label{tbl:test} at the same time.

Equations enclosed by single $ are not referenced

This works and displays as an equation on its own line:

$$(a^2 + b^2 = c^2)/\pi$$ {#eq:equation2}

This displays an inline equation, but it's not referenced, and saying [@eq:equation3] leads to eq. ??

$(a^2 + b^2 = c^2)/\pi$ {#eq:equation3}

[latex] conflict with minted package

With output to latex and when the minted package is loaded for source code highlighting, there is a conflict which prevents the latex document from compiling.

minted by default loads the float package and also provides a listoflistings command which conflicts with that in pandoc-crossref. If thispandoc-crossref command is changed in the source document to \renewcommand*\listoflistings{\listof{codelisting}{List of Listings}} then it compiles. There should be a test to see if minted is loaded and then either provide a new or renew command for listoflistings or just use the minted command.

Can't install on Windows

For some reason, pandoc-crossref won't compile/install on Windows 7. I've tried on several machines, first installing pandoc as a binary + the Haskell Platform, and then installing pandoc from source. Pandoc works fine in both instances, but pandoc-crossref does not.

Here's the install log:

Building pandoc-crossref-0.1.5.2...
Preprocessing library pandoc-crossref-0.1.5.2...
[ 1 of 17] Compiling Text.Pandoc.CrossRef.Util.Settings.Template ( src\Text\Pandoc\CrossRef\Util\Settings\Template.hs, dist\build\Text\Pandoc\CrossRef\Util\Settings\Template.o )
[ 2 of 17] Compiling Text.Pandoc.CrossRef.Util.Meta ( src\Text\Pandoc\CrossRef\Util\Meta.hs, dist\build\Text\Pandoc\CrossRef\Util\Meta.o )
[ 3 of 17] Compiling Text.Pandoc.CrossRef.Util.Template ( src\Text\Pandoc\CrossRef\Util\Template.hs, dist\build\Text\Pandoc\CrossRef\Util\Template.o )
[ 4 of 17] Compiling Text.Pandoc.CrossRef.Util.Util ( src\Text\Pandoc\CrossRef\Util\Util.hs, dist\build\Text\Pandoc\CrossRef\Util\Util.o )
[ 5 of 17] Compiling Text.Pandoc.CrossRef.Util.Accessor ( src\Text\Pandoc\CrossRef\Util\Accessor.hs, dist\build\Text\Pandoc\CrossRef\Util\Accessor.o )
[ 6 of 17] Compiling Text.Pandoc.CrossRef.References.Types ( src\Text\Pandoc\CrossRef\References\Types.hs, dist\build\Text\Pandoc\CrossRef\References\Types.o )
[ 7 of 17] Compiling Text.Pandoc.CrossRef.References.Accessors ( src\Text\Pandoc\CrossRef\References\Accessors.hs, dist\build\Text\Pandoc\CrossRef\References\Accessors.o )
[ 8 of 17] Compiling Text.Pandoc.CrossRef.Util.Settings.Gen ( src\Text\Pandoc\CrossRef\Util\Settings\Gen.hs, dist\build\Text\Pandoc\CrossRef\Util\Settings\Gen.o )
ghc.exe: unable to load package `hslua-0.4.1'
ghc.exe: warning: WSACleanup from ws2_32 is linked instead of __imp_WSACleanup
ghc.exe: warning: WSAStartup from ws2_32 is linked instead of __imp_WSAStartup
ghc.exe: warning: WSACleanup from ws2_32 is linked instead of __imp_WSACleanup
ghc.exe: warning: accept from ws2_32 is linked instead of __imp_accept
ghc.exe: warning: inet_ntoa from ws2_32 is linked instead of __imp_inet_ntoa
ghc.exe: warning: getnameinfo from ws2_32 is linked instead of __imp_getnameinfo
ghc.exe: warning: getaddrinfo from ws2_32 is linked instead of __imp_getaddrinfo
ghc.exe: warning: freeaddrinfo from ws2_32 is linked instead of __imp_freeaddrinfo
ghc.exe: warning: _tzset from msvcrt is linked instead of __imp__tzset
ghc.exe: warning: isalpha from msvcrt is linked instead of __imp_isalpha
ghc.exe: warning: GetVersionExA from kernel32 is linked instead of __imp_GetVersionExA
ghc.exe: warning: GetModuleHandleA from kernel32 is linked instead of __imp_GetModuleHandleA
ghc.exe: warning: GetProcAddress from kernel32 is linked instead of __imp_GetProcAddress
ghc.exe: warning: _snprintf from msvcrt is linked instead of __imp__snprintf
ghc.exe: warning: GetSystemInfo from kernel32 is linked instead of __imp_GetSystemInfo
ghc.exe: warning: GetSystemMetrics from user32 is linked instead of __imp_GetSystemMetrics
ghc.exe: warning: GetVersionExA from kernel32 is linked instead of __imp_GetVersionExA
ghc.exe: warning: _snprintf from msvcrt is linked instead of __imp__snprintf
ghc.exe: warning: GetSystemInfo from kernel32 is linked instead of __imp_GetSystemInfo
ghc.exe: warning: GetComputerNameA from kernel32 is linked instead of __imp_GetComputerNameA
ghc.exe: warning: CryptAcquireContextA from advapi32 is linked instead of __imp_CryptAcquireContextA
ghc.exe: warning: CryptGenRandom from advapi32 is linked instead of __imp_CryptGenRandom
ghc.exe: warning: _stat64 from msvcrt is linked instead of __imp__stat64
ghc.exe: warning: _open from msvcrt is linked instead of __imp__open
ghc.exe: warning: _stat64 from msvcrt is linked instead of __imp__stat64
ghc.exe: warning: tolower from msvcrt is linked instead of __imp_tolower
ghc.exe: warning: toupper from msvcrt is linked instead of __imp_toupper
ghc.exe: warning: isalpha from msvcrt is linked instead of __imp_isalpha
ghc.exe: warning: isalnum from msvcrt is linked instead of __imp_isalnum
ghc.exe: warning: isupper from msvcrt is linked instead of __imp_isupper
ghc.exe: warning: isgraph from msvcrt is linked instead of __imp_isgraph
ghc.exe: warning: isprint from msvcrt is linked instead of __imp_isprint
ghc.exe: warning: ispunct from msvcrt is linked instead of __imp_ispunct
ghc.exe: warning: iscntrl from msvcrt is linked instead of __imp_iscntrl
ghc.exe: warning: isupper from msvcrt is linked instead of __imp_isupper
ghc.exe: C:\Users\James\AppData\Roaming\cabal\x86_64-windows-ghc-7.10.2\hslua-0.4.1-DAXOloNJurRCYy4KgxvZeZ\HShslua-0.4.1-DAXOloNJurRCYy4KgxvZeZ.o: unknown symbol `mingw_getsp'

The key "SoftBreak" was not found - after update to pandoc 1.16

Working on a win 7 professional system with RStudio/R/rmarkdown/pandoc. Updated to pandoc 1.16 and crossref 0.1.6.3 via cabal. Seems something else needs to be updated. Result is:

pandoc-crossref.exe: Error in $[2][29]: The key "SoftBreak" was not found
pandoc.exe: Error running filter pandoc-crossref
Filter returned error status 1
Error: pandoc document conversion failed with error 83

Full output:

"C:/path/cabal/bin/pandoc" +RTS -K512m -RTS 2015HarshaText.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output 2015HarshaText.pdf --filter pandoc-citeproc --template "c:\path\default-1.14.tex" --highlight-style tango --latex-engine pdflatex --include-in-header "c:\\;path\\HABsPDFheader.tex" --filter pandoc-crossref --variable "geometry:margin=1in" --bibliography "c:\\path\\HABs.bib" 
output file: 2015HarshaText.knit.md

pandoc-citeproc: reference fig:MCStruct not found
pandoc-crossref.exe: Error in $[2][29]: The key "SoftBreak" was not found
pandoc.exe: Error running filter pandoc-crossref
Filter returned error status 1
Error: pandoc document conversion failed with error 83
In addition: Warning message:
running command '"C:/path/pandoc" +RTS -K512m -RTS 2015HarshaText.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output 2015HarshaText.pdf --filter pandoc-citeproc --template "c:\path\latex\default-1.14.tex" --highlight-style tango --latex-engine pdflatex --include-in-header "c:\\path\\HABsPDFheader.tex" --filter pandoc-crossref --variable "geometry:margin=1in" --bibliography "c:\\path\\HABs.bib"' had status 83 
Execution halted

How to get exe file for windows

Hello! Sorry for my question, but I don't know Haskell.
I want to get standalone executable file for pandoc-crossref and run it in portable way on machines where no Haskell distributive. How can I do this?

Failure to run

With pandoc 1.13.2 on OS X 10.10.3, pandoc-crossref is unusable (at least on my system):

~/.../filters/pandoc-crossref : pandoc -F pandoc-crossref.hs -i demo.md -o blah.html

pandoc-crossref.hs:152:50:
    Couldn't match expected type ‘Pandoc’
                with actual type ‘Either Text.Pandoc.Error.PandocError Pandoc’
    In the second argument of ‘($)’, namely ‘readMarkdown def s’
    In the second argument of ‘($)’, namely
      ‘getInlines $ readMarkdown def s’

pandoc-crossref.hs:167:48:
    Couldn't match expected type ‘Pandoc’
                with actual type ‘Either Text.Pandoc.Error.PandocError Pandoc’
    In the second argument of ‘($)’, namely ‘readMarkdown def s’
    In the second argument of ‘($)’, namely
      ‘getBlocks $ readMarkdown def s’

pandoc-crossref.hs:179:9:
    Non type-variable argument
      in the constraint: MonadState References m
    (Use FlexibleContexts to permit this)
    When checking that ‘withTmplV’ has the inferred type
      withTmplV :: forall (m :: * -> *) b.
                   MonadState References m =>
                   (String -> Maybe MetaValue) -> m b -> m b
    In an equation for ‘applyTemplate’:
        applyTemplate i t tmpl
          = withTmplV internalVars $ replaceTemplate tmpl
          where
              withTmplV f g
                = do { modify $ ...;
                       .... }
              internalVars "i" = Just $ MetaInlines i
              internalVars "t" = Just $ MetaInlines t
              internalVars _ = Nothing
pandoc: Error running filter pandoc-crossref.hs

Feature Request: Reference without link

Thank you for a great package - works great!
Is it possible to create references in text without the link? Either for the entire document or on a per reference basis.
I tried redefining the \ref to use \ref* in the metadata of my file but couldn't make it work. I then tried hiding the links with \hypersetup[hidelinks] - this hid the links but broke my custom "figureTitle" and "figPrefix" (by the way, I can never make "titleDelimiter" work).
I was thinking that, selective suppression might be accomplished by using /ref* instead of /ref when the reference is called with a "-" before the reference like this "-@fig:figure1". This syntax is similar to "pandoc-citeproc" where "-@citekey" suppresses mention of the author in the citation. Unfortunately, I don't have the coding skills to contribute to the this.
And again, thank you for the great work on this package!

Context Support

How difficult would it be to add Context support to this? The referencing syntax is fairly simple at its most basic:

"The command \in provides the number of a chapter, section, figure, table, etc. The command \at produces a pagenumber and \about produces a complete title."

You can refer simply by using \in[fig:thefigure], which will create a reference link to the number where only the number is a clickable link. If you want the link to include more than just the number you can do \in {figure} [fig:thefigure], which would create a clickable link of "Figure 1".

Crossref along citeproc: Multiple references.

FIrst of all, thanks for creating such filter, it was something I was looking for for a long time.

I am having issues running crossref along citeproc. The problem is that once crossref has run, it splits my in text references from

[@Dean1998a; @Verpoorter2014]

to

[@Dean1998a], [@Verpoorter2014]

Making it so that I can't have my in text references as "(Dean and Gorham, 1998; Verpoorter et al., 2014)" but as (Dean and Gorham, 1998), (Verpoorter et al., 2014).

Is there anyway that this can be fixed?

Cheers!

support for formatting of labels

Often, labels are printed in bold or italics, i. e.

Figure 1: The solar system.

It would be great to use markdown syntax in the YAML parameters to format the table and figure labels. I. e. -M "figureTitle:**Figure #**"

BTW: In Latex it works out of the box because it can be configured with the package ccaption, for instance.

master fails on Windows spectacularly

Evidently, import Text.Pandoc.Shared (normalizeInlines) triggers the following behavior:

D:\Develop\git\pandoc-crossref>pandoc --filter ./pandoc-crossref.hs -o demo.pdf test.md
pandoc-crossref.hs: warning: inet_ntoa from ws2_32 is linked instead of __imp_inet_ntoa
pandoc-crossref.hs: warning: getnameinfo from ws2_32 is linked instead of __imp_getnameinfo
pandoc-crossref.hs: warning: getaddrinfo from ws2_32 is linked instead of __imp_getaddrinfo
pandoc-crossref.hs: warning: freeaddrinfo from ws2_32 is linked instead of __imp_freeaddrinfo
pandoc-crossref.hs: warning: accept from ws2_32 is linked instead of __imp_accept
pandoc-crossref.hs: warning: WSACleanup from ws2_32 is linked instead of __imp_WSACleanup
pandoc-crossref.hs: warning: WSAStartup from ws2_32 is linked instead of __imp_WSAStartup
pandoc-crossref.hs: warning: WSACleanup from ws2_32 is linked instead of __imp_WSACleanup
pandoc-crossref.hs: warning: _vsnprintf from msvcrt is linked instead of __imp__vsnprintf
pandoc-crossref.hs: warning: GetVersionExA from kernel32 is linked instead of __imp_GetVersionExA
pandoc-crossref.hs: warning: GetModuleHandleA from kernel32 is linked instead of __imp_GetModuleHandleA
pandoc-crossref.hs: warning: GetProcAddress from kernel32 is linked instead of __imp_GetProcAddress
pandoc-crossref.hs: warning: _snprintf from msvcrt is linked instead of __imp__snprintf
pandoc-crossref.hs: warning: GetSystemInfo from kernel32 is linked instead of __imp_GetSystemInfo
pandoc-crossref.hs: warning: GetSystemMetrics from user32 is linked instead of __imp_GetSystemMetrics
pandoc-crossref.hs: warning: GetVersionExA from kernel32 is linked instead of __imp_GetVersionExA
pandoc-crossref.hs: warning: _snprintf from msvcrt is linked instead of __imp__snprintf
pandoc-crossref.hs: warning: GetSystemInfo from kernel32 is linked instead of __imp_GetSystemInfo
pandoc-crossref.hs: warning: GetComputerNameA from kernel32 is linked instead of __imp_GetComputerNameA
pandoc-crossref.hs: warning: CryptAcquireContextA from advapi32 is linked instead of __imp_CryptAcquireContextA
pandoc-crossref.hs: warning: CryptGenRandom from advapi32 is linked instead of __imp_CryptGenRandom
pandoc-crossref.hs: warning: _stat64 from msvcrt is linked instead of __imp__stat64
pandoc-crossref.hs: warning: _open from msvcrt is linked instead of __imp__open
pandoc-crossref.hs: warning: _stat64 from msvcrt is linked instead of __imp__stat64
pandoc-crossref.hs: warning: tolower from msvcrt is linked instead of __imp_tolower
pandoc-crossref.hs: warning: toupper from msvcrt is linked instead of __imp_toupper
pandoc-crossref.hs: warning: isalpha from msvcrt is linked instead of __imp_isalpha
pandoc-crossref.hs: warning: isalnum from msvcrt is linked instead of __imp_isalnum
pandoc-crossref.hs: warning: isupper from msvcrt is linked instead of __imp_isupper
pandoc-crossref.hs: warning: isgraph from msvcrt is linked instead of __imp_isgraph
pandoc-crossref.hs: warning: isprint from msvcrt is linked instead of __imp_isprint
pandoc-crossref.hs: warning: ispunct from msvcrt is linked instead of __imp_ispunct
pandoc-crossref.hs: warning: iscntrl from msvcrt is linked instead of __imp_iscntrl
pandoc-crossref.hs: warning: isupper from msvcrt is linked instead of __imp_isupper
pandoc-crossref.hs: C:\Users\Walter\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\hslua-0.3.13\HShslua-0.3.13.o: unknown symbol `mingw_getsp'
pandoc-crossref.hs: pandoc-crossref.hs: unable to load package `hslua-0.3.13'
pandoc: Error running filter ./pandoc-crossref.hs

May be related to https://ghc.haskell.org/trac/ghc/ticket/9868

Referencing/Numbering broken with new pandoc version 1.16

With the newest pandoc version 1.16/1.17 and pandoc-crossref the referencing and numbering of figures is completely broken.

The caption changes to Figure 1: Figure 1: caption and the reference just to See fig. .

I applied pandoc pull request 2637 already but it did not help.

How to reproduce:

# Figure Test

See @fig:figure1.

![First figure](img1.jpg){#fig:figure1}

pandoc -s -o test_figures.pdf -F pandoc-crossref.exe test_figures.md

Loosen restrictions on yaml settings

This is not really an issue, more of a feature suggestion. Currently, if the yaml setting file starts with an empty line or a line of three dashes (like yaml front matter in a pandoc document), it is silently ignored. Subsequent blank lines do not seem to matter, but options are not read after a --- line somewhere in the yaml file.

It would be great if:

  • the parser could ignore blank and --- lines in the yaml, and still work (though I am not sure this would follow yaml guidelines, I don't know much about it)
  • at least give a warning if a -M "crossrefYaml=settings.yaml" is given but no option has been found.

We could also mention in the README that the yaml file's first line needs to be setting an option.

figureTitle doesn't work with PDF output

Hi! Thanks for paddoc-crossref! =)

The config figureTitle works fine for HTML output. But it seems not to work with PDF output. I'm getting "Figure: ..." anyway.
Didn't set the Latex template, so it should be using Pandoc's default.
Tried setting figureTemplate, but made no difference neither.
Using: pandoc-crossref-0.1.0.2

installation is cumbersome

Hi and thanks for the package!
I've installed pandoc via brew and to use this filter I have to get haskell (1.6Gb installed) plus 83 packages. In the meantime, I've managed to drink a cup of coffee and create this issue, and the compiling is still not done!

Not sure there is an easy fix of this, I guess the dependencies are mainly due to pandoc? Anyhow, seems cumbersome just for some text parsing.

Here are the packages:

base64-bytestring-1.0.0.1 (new package)
blaze-builder-0.4.0.1 (new package)
blaze-markup-0.7.0.2 (new package)
blaze-html-0.8.0.2 (new package)
byteable-0.1.1 (new package)
cereal-0.4.1.1 (new package)
cryptohash-0.11.6 (new package)
data-default-class-0.0.1 (new package)
cookie-0.4.1.5 (new package)
data-default-instances-base-0.0.1 (new package)
data-default-instances-containers-0.0.1 (new package)
data-default-instances-old-locale-0.0.1 (new package)
deepseq-generics-0.1.1.2 (new package)
digest-0.0.1.2 (new package)
dlist-0.7.1.1 (new package)
data-default-instances-dlist-0.0.1 (new package)
data-default-0.5.3 (new package)
extensible-exceptions-0.1.1.4 (new package)
hourglass-0.2.9 (new package)
asn1-types-0.3.0 (new package)
http-types-0.8.6 (new package)
mime-types-0.1.0.6 (new package)
nats-1 (new package)
network-2.6.1.0 (new version)
scientific-0.3.3.8 (new package)
attoparsec-0.11.3.4 (latest: 0.13.0.0) (new version)
securemem-0.1.7 (new package)
crypto-cipher-types-0.0.9 (new package)
cipher-aes-0.2.10 (new package)
cipher-des-0.0.6 (new package)
cipher-rc4-0.1.4 (new package)
crypto-random-0.0.9 (new package)
crypto-numbers-0.2.7 (new package)
semigroups-0.16.2.2 (new package)
socks-0.5.4 (new package)
tagsoup-0.13.3 (new package)
transformers-0.4.3.0 (new version)
haddock-library-1.2.0 (new package)
mmorph-1.0.4 (new package)
mtl-2.2.1 (new version)
JuicyPixels-3.2.4 (new package)
aeson-0.7.0.6 (latest: 0.8.1.0) +new-bytestring-builder (new package)
asn1-encoding-0.9.0 (new package)
asn1-parse-0.9.1 (new package)
crypto-pubkey-types-0.4.3 (new package)
crypto-pubkey-0.2.8 (new package)
hslua-0.3.13 (new package)
pandoc-types-1.12.4.2 (new package)
parsec-3.1.9 (new version)
network-uri-2.6.0.3 (new package)
HTTP-4000.2.19 (new version)
pem-0.2.2 (new package)
regex-base-0.93.2 (reinstall) changes: mtl-2.1.3.1 -> 2.2.1
regex-pcre-builtin-0.94.4.8.8.35 (new package)
streaming-commons-0.1.12 (new package)
transformers-compat-0.4.0.4 (new package)
exceptions-0.8.0.2 (new package)
http-client-0.4.11.2 (new package)
temporary-1.2.0.3 (new package)
transformers-base-0.4.4 (new package)
monad-control-1.0.0.4 (new package)
lifted-base-0.2.3.6 (new package)
enclosed-exceptions-1.0.1.1 (new package)
resourcet-1.1.4.1 (new package)
utf8-string-1 (new package)
highlighting-kate-0.5.15 (new package)
void-0.7 (new package)
conduit-1.2.4.2 (new package)
x509-1.5.0.1 (new package)
x509-store-1.5.0 (new package)
x509-system-1.5.0 (new package)
x509-validation-1.5.2 (new package)
tls-1.2.17 (new package)
connection-0.2.4 (new package)
http-client-tls-0.2.2 (new package)
xml-1.3.14 (new package)
texmath-0.8.2 (new package)
yaml-0.8.11 (new package)
zip-archive-0.2.3.7 (new package)
pandoc-1.13.2.1 (new package)
pandoc-crossref-0.1.0.2 (new package)

Might note also that the install needs --force-reinstall on a clean system:

cabal: The following packages are likely to be broken by the reinstalls:
regex-posix-0.95.2
regex-compat-0.95.1
Use --force-reinstalls if you want to install anyway.

Possibility to do the opposite: LaTeX -> markdown?

I'm currently writing in markdown and use pandoc and pandoc-crossref to convert markdown to LaTeX. But my collaborators only use LaTeX. So after they modified my LaTeX file, are there any chances to convert it back to markdown, with the same cross-reference format suggested by pandoc-crossref? Currently when I tried to do that, the format of both the labels and the references are messed up.

Thanks a lot!

Add documentation on how to run using docker

This is more of a question than an issue. I currently maintain a docker repository with an image that contains pandoc, pandoc-citeproc and pandoc-crossref. If there's interest, I can add to the README a quick how-to section on running the demo using this docker image.

ignore unlabeled images

Currently, the filter requires that all images are labeled (in contrast to tables). If one image is unlabeled, the following error occurs and conversion is stopped:

pandoc-crossref.hs: Prelude.last: empty list
pandoc: Error running filter ./pandoc-crossref.hs

It took a while to figure this out in my large multiple file project.

It would be nice if the filter would just print a warning message (maybe in verbose mode only).

support numbering by chapters

If the parameter --chapters is given to pandoc, all crossref numbers should be prefixed with the chapter number and restarted at 1 for each chapter.

Currently, they will be simply incremented across the whole document.

too much space between "Figure" and reference

This filter seems to put an additional space between Figure and the number, so instead of Figure~\ref it writes: Figure~ \ref, which makes LaTeX output Figure 5 with two spaces between Figure and 5. Screenshot:

screenshot from 2015-05-03 12-56-07

In-paragraph equation number needed

pandoc-crossref is a great unified filter for figure/table/equation numbering.

But equation label only works if display math and label specification are in a paragraph of its own. That results in a big skip before the equation and a new paragraph after it, whereas the equation and texts around it should remain in a same paragraph in most cases.

Would you please make the equation labels can be used with equations NOT in a paragraph of its own?

It'd be nice if equation labels can be used as pandoc-eqnos does, its demo.md shows this feature.

Links between Figure Citations and the Figure

Hi,

I am converting from markdown to HTML.

I am currently creating a figure like this:

![LC male and female duplex connector](images/lcconnector.png){#fig:lcconnector}

and I am referencing it like this:

An LC connector [[@fig:lcconnector]] is a common connection type seen on fibre cables.

The reference is parsed correctly and the correct figure number appears in the output. However there is no internal hyperlink in the citation. I looked at the raw HTML and the img tag already has an id attribute set (fig:lcconnector). The citation (in raw HTML) only needs to change from:

[Fig 5.] to <a href="#fig:lcconnector">[Fig. 5]</a>

Am I missing the way to do this or is this feature not available?

I'm using the latest version of all tools as far as I can tell.

I am using the following command line:

pandoc -s -S -c test.css --csl default.csl --metadata link-citations=true --filter pandoc-crossref --filter pandoc-citeproc --bibliography mybib.bib --number-sections input.markdown -o manual.html

Thanks for your efforts on this filter, it's been very useful for me so far and much more enjoyable than using Microsoft Word. That's a compliment even if it doesn't sound like one. :)

Best Regards,

Captions for code listings produce \begin{codelisting} which is not in the listings package

If I use either

Listing: Foo
```{#lst:mypython .python .numberLines}
..somecode...

Or

```{#lst:mypython .python .numberLines caption="Foo"}
...somecode...

This produces following latex compilation error:

! LaTeX Error: Environment codelisting undefined.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.48     \begin{codelisting}

pandoc: Error producing PDF from TeX source

I cannot find any package for a codelisting environment with google, so would you please tell me how I can fix this?

For compiling to HTML, everything works as expected.

no latex commands are allowed after label definition

Just a tiny issue and maybe only for documentation purposes:

Currently, it is not allowed to have some characters or even latex commands after a label definition.

I. e. ![First figure](img1.jpg){#fig:figure1}\todo{write better description} is not allowed. Just {#fig:figure1} is printed. Spaces are allowed.

Okay, it even does not work without the label definition. So probably a pandoc parsing issue or just a syntax violation?

.docx support?

Hi, are .docx files supported?. With the following foo.tex file:

\documentclass{article}
\usepackage{amsmath}
\usepackage{cleveref}
\begin{document}
\begin{equation}
\label{eq:first}
  1 + 1 = 2
\end{equation}
\cref{eq:first}
\end{document}

If I run pandoc -s --filter pandoc-crossref foo.tex -o foo.docx I get:
asdasdasdasdas

Thanks!

Provide a library to use in hakyll/gitit/etc [was: pandoc-crossref, bibtex and hakyll]

Hi,
I'm trying to put bibtex and pandoc-crossref to work in a Hakyll wiki config.
I have this almost default code:

match "posts/*" $ do
        route $ setExtension "html"
        compile $ do
            -- modification begin
            item <- getUnderlying
            bibFile <- liftM (fromMaybe "") $ getMetadataField item "biblio"
            cslFile <- liftM (fromMaybe "chicago") $ getMetadataField item "csl"
            let compiler = if bibFile /= ""
                then bibtexCompiler cslFile bibFile
                else pandocCompilerWithTransformM defaultHakyllReaderOptions pandocOptions (transformer "pandoc-crossref" defaultHakyllReaderOptions pandocOptions)
            compiler
            -- modification end
                >>= loadAndApplyTemplate "templates/post.html"    postCtx
                >>= loadAndApplyTemplate "templates/default.html" postCtx
                >>= relativizeUrls

If the post has a bibtex file attached, process the bibtex, else skip bibtex processing, working only with the pandoc-crossref.

My problem is the bibtexCompiler code. I want to put pandoc-crossref inside it:

bibtexCompiler :: String -> String -> Compiler (Item String)
bibtexCompiler cslFileName bibFileName = do 
    csl <- load (fromFilePath $ "csl/"++cslFileName)
    bib <- load (fromFilePath $ "bib/"++bibFileName)
    --liftM (writePandocWith pandocOptions)
    --    (getResourceBody >>= readPandocBiblio def csl bib)
    writePandocWith pandocOptions <$>
        (traverse transformer "pandoc-crossref" def pandocOptions =<< readPandocBiblio def csl bib =<< getResourceBody)

transformer  :: Script  -> ReaderOptions  -> WriterOptions -> (Pandoc -> Compiler Pandoc)
transformer script reader_opts writer_opts pandoc = 
    do let input_json = writeJSON writer_opts pandoc
       output_json <- unixFilter script [] input_json
       return $ 
          either (error.show) id $  -- this line needs to be uncommented atm.
          readJSON reader_opts output_json 

I've seen the code for pandocCompilerWithTransformM:

pandocCompilerWithTransformM :: ReaderOptions -> WriterOptions
                    -> (Pandoc -> Compiler Pandoc)
                    -> Compiler (Item String)
pandocCompilerWithTransformM ropt wopt f =
    writePandocWith wopt <$>
        (traverse f =<< readPandocWith ropt =<< getResourceBody)

That's why I'm trying to use this code, replacing readPandocWith ropt with readPandocBiblio def csl bib, which has the same return type. But it doesn't work.

It compiles and runs correctly, and it shows the bibliography and the Figure 1, but the citation shows [@author], even though it shows [1]. The reason I create the issue here is that whether I remove the traverse transformer ..., the citation works (it shows [1]), but the pandoc-crossref not.

Thanks

feature request: link cross references

The pandoc-citeref filter has an option (link-citations) to link the cross references in html and latex output: clicking on the reference jumps to the corresponding entry in the bibliography.
Would it be possible to add something alike to pandoc-crossref?

One of the things that needs to happen for this is adding id's to the figures and tables in html. This would also be beneficial for other things such as targeting specific images with css, or adding page numbers (using target-counter(attr(href), page) in css) to the list of figures in html.

[README] Add docs on pandoc-citeproc compatibility

Hi,

I could not get the figures to cross reference initially, but this is because I was running pandoc with citeproc first. When I ran just pandoc-crossref it worked. I don't know if this is a problem with crossref or citeproc or just the way I'm doing it. Either way I'm letting other people know if they face a similar issue.

This didn't work:

pandoc -s -S -c test.css --csl default.csl --metadata link-citations=true --filter pandoc-citeproc --filter pandoc-crossref --bibliography mybib.bib --number-sections input.markdown -o manual.html

When I changed them round to the following it worked:

pandoc -s -S -c test.css --csl default.csl --metadata link-citations=true --filter pandoc-crossref --filter pandoc-citeproc --bibliography mybib.bib --number-sections input.markdown -o manual.html

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.