* Conversion tex to docx - endfloat package? @ 2015-11-26 12:39 Rainer M Krug [not found] ` <7e3777d8-7ceb-4493-83bc-3b972a1cdb76-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 0 siblings, 1 reply; 7+ messages in thread From: Rainer M Krug @ 2015-11-26 12:39 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1.1: Type: text/plain, Size: 1110 bytes --] 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? Thanks, Rainer -- You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/7e3777d8-7ceb-4493-83bc-3b972a1cdb76%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. [-- Attachment #1.2: Type: text/html, Size: 1594 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <7e3777d8-7ceb-4493-83bc-3b972a1cdb76-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>]
* Re: Conversion tex to docx - endfloat package? [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 ` (2 subsequent siblings) 3 siblings, 0 replies; 7+ messages in thread From: BP Jonsson @ 2015-11-26 15:30 UTC (permalink / raw) To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw Den 2015-11-26 kl. 13:39, skrev Rainer M Krug: > 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? > > Thanks, > > Rainer You could write a filter which moves them there: * traverse the AST looking for figures and tables. * append each one found to a global list variable. * Remove the found float or replace it with something which produces no output, in the place where it used to be. * After traversal append the list with the floats at the end of the document data list. /bpj ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Conversion tex to docx - endfloat package? [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 14:48 ` Rainer M Krug 2015-11-27 19:42 ` John MacFarlane 3 siblings, 1 reply; 7+ messages in thread From: BP Jonsson @ 2015-11-26 19:31 UTC (permalink / raw) To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw Den 2015-11-26 kl. 13:39, skrev Rainer M Krug: > 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? I should have mentioned before that pandoc doesn't compile the LaTeX, it just parses the LaTeX markup into an AST, discarding anything it cannot represent, and builds a document in another format from the AST. However pandoc lets you run filters on the AST after having read the original document and before constructing the new document, and it is (was) fairly simple towrite a filter which collects all figures and tables at a designated place in the document. You can read about using filters here: <https://github.com/jgm/pandoc/blob/master/README#L400> You can find such a filter as I described before here: <https://gist.github.com/bpj/f591a9e29fe974fa791f> There are both a perl and a python version. Make sure to read the description! EDIT: it occurs to me that you sprobably want to put all tables together in one place and all figures together in another place. Reply to this mail if that is the case! /bpj ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <56575DF7.2050202-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: Conversion tex to docx - endfloat package? [not found] ` <56575DF7.2050202-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2015-11-27 9:37 ` Rainer M Krug 0 siblings, 0 replies; 7+ messages in thread From: Rainer M Krug @ 2015-11-27 9:37 UTC (permalink / raw) To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw; +Cc: BP Jonsson [-- Attachment #1: Type: text/plain, Size: 2579 bytes --] BP Jonsson <bpj-J3H7GcXPSITLoDKTGw+V6w-XMD5yJDbdMReXY1tMh2IBg@public.gmane.org> writes: > Den 2015-11-26 kl. 13:39, skrev Rainer M Krug: >> 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? > > I should have mentioned before that pandoc doesn't compile the LaTeX, > it just parses the LaTeX markup into an AST, discarding anything it > cannot represent, and builds a document in another format from the > AST. > > However pandoc lets you run filters on the AST after having read the > original document and before constructing the new document, > and it is (was) fairly simple towrite a filter which collects all > figures and tables at a designated place in the document. Yes - I was aware if this, and I have other issues because of this as well (siunitx package). > > You can read about using filters here: > > <https://github.com/jgm/pandoc/blob/master/README#L400> Thanks - useful resource. > > You can find such a filter as I described before here: > > <https://gist.github.com/bpj/f591a9e29fe974fa791f> > > There are both a perl and a python version. > Make sure to read the description! > > EDIT: it occurs to me that you sprobably want to put all tables > together in one place and all figures together in another place. > Reply to this mail if that is the case! Yes - this is exactly what I want to do. I want to collect all table and figure floats at the end, ideally one section with the header "Figures" with the figures, a scond header with the name "Tables" with the table floats. I tried your filters in a make file as follow: ,---- | sed -e 's/pdf/png/g' ASMOptim.tex > ASMOptim.pandoc.tex | pandoc --bibliography=ASMOptim.bib --filter pandoc-collect-floats.pl --filter pandoc-citeproc ASMOptim.pandoc.tex -o ASMOptim_0.1.4+.docx | pandoc: Error running filter pandoc-collect-floats.pl | fd:4: hClose: resource vanished (Broken pipe) `---- but as you can see, the filter pandoc-collect-floats.pl raises an error. Any ideas what is causing this? Thanks a lot, Rainer > > /bpj > -- Rainer M. Krug email: Rainer<at>krugs<dot>de PGP: 0x0F52F982 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Conversion tex to docx - endfloat package? [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 @ 2015-11-27 14:48 ` Rainer M Krug 2015-11-27 19:42 ` John MacFarlane 3 siblings, 0 replies; 7+ messages in thread From: Rainer M Krug @ 2015-11-27 14:48 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1.1: Type: text/plain, Size: 1410 bytes --] BP Jonsson wrote a brilliant filter for this which can be found at https://gist.github.com/bpj/f591a9e29fe974fa791f#file-pandoc-collect-floats-py which works very nicely. Thanks BP, Rainer On Thursday, November 26, 2015 at 1:39:06 PM UTC+1, Rainer M Krug wrote: > > 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? > > Thanks, > > Rainer > -- You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/9dfdbcf8-3fb7-4546-a3f4-cee26355327e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. [-- Attachment #1.2: Type: text/html, Size: 2040 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Conversion tex to docx - endfloat package? [not found] ` <7e3777d8-7ceb-4493-83bc-3b972a1cdb76-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> ` (2 preceding siblings ...) 2015-11-27 14:48 ` Rainer M Krug @ 2015-11-27 19:42 ` John MacFarlane [not found] ` <20151127194235.GA49129-jF64zX8BO091tJRe0FUodcM6rOWSkUom@public.gmane.org> 3 siblings, 1 reply; 7+ messages in thread From: John MacFarlane @ 2015-11-27 19:42 UTC (permalink / raw) To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw +++ 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <20151127194235.GA49129-jF64zX8BO091tJRe0FUodcM6rOWSkUom@public.gmane.org>]
* Re: Conversion tex to docx - endfloat package? [not found] ` <20151127194235.GA49129-jF64zX8BO091tJRe0FUodcM6rOWSkUom@public.gmane.org> @ 2022-01-09 17:11 ` Christopher Barrington-Leigh 0 siblings, 0 replies; 7+ messages in thread From: Christopher Barrington-Leigh @ 2022-01-09 17:11 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1.1: Type: text/plain, Size: 1960 bytes --] This BP Jonsson filter apparently doesn't work with any recent pandoc. I am trying to convert latex to odt, moving floats (which aren't rendered well at all) to the end. Is anyone doing this successfully? On Friday, 27 November 2015 at 14:42:51 UTC-5 John MacFarlane wrote: > +++ 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 > > -- You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/f2028dcb-18b2-40b5-aba3-98c58135c270n%40googlegroups.com. [-- Attachment #1.2: Type: text/html, Size: 2701 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-01-09 17:11 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-11-26 12:39 Conversion tex to docx - endfloat package? 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 [not found] ` <20151127194235.GA49129-jF64zX8BO091tJRe0FUodcM6rOWSkUom@public.gmane.org> 2022-01-09 17:11 ` Christopher Barrington-Leigh
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).