public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org>
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: Conversion tex to docx - endfloat package?
Date: Fri, 27 Nov 2015 11:42:35 -0800	[thread overview]
Message-ID: <20151127194235.GA49129@MacBook-Air-2.local> (raw)
In-Reply-To: <7e3777d8-7ceb-4493-83bc-3b972a1cdb76-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>

+++ Rainer M Krug [Nov 26 15 04:39 ]:
>   Hi
>   I am using pandoc to convert a tex document to docx for my co-authors
>   (which works very nicely!), and they want to have figures and tables at
>   the end of the document.
>   I am using in LaTeX the package endfloat for this. Using pdflatex, this
>   works perfectly to generate the pdf, but when I use pandoc to convert
>   the tex to a docx, the package "endfloat" is ignored and all floats are
>   where they would be without "endfloat".
>   Is there a way to force all floats (figures and tables) to the end of
>   the document in pandoc?

The only way I can think of would be to write a filter that
moves all the tables and figures to the end of the document.
Note: the following is untested, but something like this
should work:

-- floatsToEnd.hs
import Text.Pandoc.JSON
import Text.Pandoc.Walk

main :: IO ()
main = toJSONFilter floatsToEnd

floatsToEnd :: Pandoc -> Pandoc
floatsToEnd (Pandoc meta bs) =
  Pandoc meta $ walk (remove isFloat) bs ++ query isFloat bs

isFloat :: Block -> Bool
isFloat (Table{}) = True
isFloat (Para [Image{}]) = True
isFloat _ = False

remove :: (Block -> Bool) -> Block -> Block
remove pred b | pred b    = Null
              | otherwise = b


  parent reply	other threads:[~2015-11-27 19:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-26 12:39 Rainer M Krug
     [not found] ` <7e3777d8-7ceb-4493-83bc-3b972a1cdb76-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-11-26 15:30   ` BP Jonsson
2015-11-26 19:31   ` BP Jonsson
     [not found]     ` <56575DF7.2050202-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-27  9:37       ` Rainer M Krug
2015-11-27 14:48   ` Rainer M Krug
2015-11-27 19:42   ` John MacFarlane [this message]
     [not found]     ` <20151127194235.GA49129-jF64zX8BO091tJRe0FUodcM6rOWSkUom@public.gmane.org>
2022-01-09 17:11       ` Christopher Barrington-Leigh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151127194235.GA49129@MacBook-Air-2.local \
    --to=jgm-tvlzxgkolnx2fbvcvol8/a@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).