Reference file for docx?

Showing 1-11 of 11 messages
Reference file for docx? Carl Boettiger 4/18/12 6:50 PM
Hi,

I'm trying to define a reference.docx file in order to set default fonts and colors (i.e. don't use color in the headings, use a monospace font for source blocks, double space text), but I'm not having any luck -- pandoc output looks the same as if I had no reference file at all.  Not sure what I'm doing wrong here. 

I'm running the command as:
pandoc --reference-docx=reference.docx rfishbase.md -o rfishbase.docx

My reference.docx and rfishbase.md are available here if anyone wants to test.  Any pointers or working examples on how templating is supposed to work?  (I created reference.docx with pandoc, modified the fonts, spacing, etc in libreoffice and saved as reference.docx). 

Thanks!
--
Carl Boettiger
UC Davis
http://www.carlboettiger.info/

Re: Reference file for docx? Joost 4/19/12 12:47 AM
On Wed, Apr 18, 2012 at 06:50:31PM -0700, Carl Boettiger wrote:
> (I created reference.docx with pandoc,
> modified the fonts, spacing, etc in libreoffice and saved as
> reference.docx).

libreoffice may be the culprit here. i've had no luck getting templates in
.doc files working in openoffice in the past. (i'd open a .doc file in
openoffice, modify the template, save again as .doc and poof, next time i'd
open the file, the original formatting was restored. saving the file as
.odt and then editing the template worked fine.)

of course, you're using libreoffice and .docx rather than openoffice and
.doc, but they may suffer from the same problem. if it's somehow an option,
try editing your reference .docx in word and see if that works.

--
Joost Kremers
Life has its moments

Re: Reference file for docx? fiddlosopher 4/19/12 12:51 AM
If you're really hard-core, you can edit your reference.docx in emacs.  It's just a zip file, after all, and if you open it in emacs, it will show you the files within and allow you to change them.  The one you want to modify is word/styles.xml.  Search for 'color' and you'll find what you need to modify.

John


--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To post to this group, send email to pandoc-...@googlegroups.com.
To unsubscribe from this group, send email to pandoc-discus...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pandoc-discuss?hl=en.


Re: Reference file for docx? Carl Boettiger 4/19/12 8:55 AM
Thanks, I'll give this a try.  No idea that they were just zip files, that's sweet.

I did try the same approach as before using odt files and reference-odt=reference.odt, but pandoc still seems to be ignoring my reference file entirely.  Surely libreoffice should work for the native format? 

Thanks again,
-Carl


On Thursday, April 19, 2012 12:51:15 AM UTC-7, fiddlosopher wrote:
If you're really hard-core, you can edit your reference.docx in emacs.  It's just a zip file, after all, and if you open it in emacs, it will show you the files within and allow you to change them.  The one you want to modify is word/styles.xml.  Search for 'color' and you'll find what you need to modify.

John


On Thu, Apr 19, 2012 at 12:47 AM, Joost Kremers <> wrote:
On Wed, Apr 18, 2012 at 06:50:31PM -0700, Carl Boettiger wrote:
> (I created reference.docx with pandoc,
> modified the fonts, spacing, etc in libreoffice and saved as
> reference.docx).

libreoffice may be the culprit here. i've had no luck getting templates in
.doc files working in openoffice in the past. (i'd open a .doc file in
openoffice, modify the template, save again as .doc and poof, next time i'd
open the file, the original formatting was restored. saving the file as
.odt and then editing the template worked fine.)

of course, you're using libreoffice and .docx rather than openoffice and
.doc, but they may suffer from the same problem. if it's somehow an option,
try editing your reference .docx in word and see if that works.

--
Joost Kremers
Life has its moments

--




On Thursday, April 19, 2012 12:51:15 AM UTC-7, fiddlosopher wrote:
If you're really hard-core, you can edit your reference.docx in emacs.  It's just a zip file, after all, and if you open it in emacs, it will show you the files within and allow you to change them.  The one you want to modify is word/styles.xml.  Search for 'color' and you'll find what you need to modify.

John


On Thu, Apr 19, 2012 at 12:47 AM, Joost Kremers <> wrote:
On Wed, Apr 18, 2012 at 06:50:31PM -0700, Carl Boettiger wrote:
> (I created reference.docx with pandoc,
> modified the fonts, spacing, etc in libreoffice and saved as
> reference.docx).

libreoffice may be the culprit here. i've had no luck getting templates in
.doc files working in openoffice in the past. (i'd open a .doc file in
openoffice, modify the template, save again as .doc and poof, next time i'd
open the file, the original formatting was restored. saving the file as
.odt and then editing the template worked fine.)

of course, you're using libreoffice and .docx rather than openoffice and
.doc, but they may suffer from the same problem. if it's somehow an option,
try editing your reference .docx in word and see if that works.

--
Joost Kremers
Life has its moments

--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.



On Thursday, April 19, 2012 12:51:15 AM UTC-7, fiddlosopher wrote:
If you're really hard-core, you can edit your reference.docx in emacs.  It's just a zip file, after all, and if you open it in emacs, it will show you the files within and allow you to change them.  The one you want to modify is word/styles.xml.  Search for 'color' and you'll find what you need to modify.

John


On Thu, Apr 19, 2012 at 12:47 AM, Joost Kremers > wrote:
On Wed, Apr 18, 2012 at 06:50:31PM -0700, Carl Boettiger wrote:
> (I created reference.docx with pandoc,
> modified the fonts, spacing, etc in libreoffice and saved as
> reference.docx).

libreoffice may be the culprit here. i've had no luck getting templates in
.doc files working in openoffice in the past. (i'd open a .doc file in
openoffice, modify the template, save again as .doc and poof, next time i'd
open the file, the original formatting was restored. saving the file as
.odt and then editing the template worked fine.)

of course, you're using libreoffice and .docx rather than openoffice and
.doc, but they may suffer from the same problem. if it's somehow an option,
try editing your reference .docx in word and see if that works.

--
Joost Kremers
Life has its moments

--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.




On Thursday, April 19, 2012 12:51:15 AM UTC-7, fiddlosopher wrote:
If you're really hard-core, you can edit your reference.docx in emacs.  It's just a zip file, after all, and if you open it in emacs, it will show you the files within and allow you to change them.  The one you want to modify is word/styles.xml.  Search for 'color' and you'll find what you need to modify.

John


On Thu, Apr 19, 2012 at 12:47 AM, Joost Kremers <> wrote:
On Wed, Apr 18, 2012 at 06:50:31PM -0700, Carl Boettiger wrote:
> (I created reference.docx with pandoc,
> modified the fonts, spacing, etc in libreoffice and saved as
> reference.docx).

libreoffice may be the culprit here. i've had no luck getting templates in
.doc files working in openoffice in the past. (i'd open a .doc file in
openoffice, modify the template, save again as .doc and poof, next time i'd
open the file, the original formatting was restored. saving the file as
.odt and then editing the template worked fine.)

of course, you're using libreoffice and .docx rather than openoffice and
.doc, but they may suffer from the same problem. if it's somehow an option,
try editing your reference .docx in word and see if that works.

--
Joost Kremers
Life has its moments

--
 
Re: Reference file for docx? BP Jonsson 4/20/12 7:41 AM
On 2012-04-19 17:55, Carl Boettiger wrote:
> I did try the same approach as before using odt files and
> reference-odt=reference.odt, but pandoc still seems to be ignoring my
> reference file entirely.  Surely libreoffice should work for the native
> format?

Are you saving your reference.odt in the right place?
It should live directly under ~/.pandoc and not in
~/.pandoc/templates if I understand correctly.

See <http://johnmacfarlane.net/pandoc/README.html>
(search for 'reference.odt').

Or should it be a *directory* called 'reference.odt'?
The wording isn't quite clear.

/bpj

Re: Reference file for docx? fiddlosopher 4/20/12 9:00 AM
No, you were right - a file ~/.pandoc/reference.odt.  Or you can explicitly specify a path using --reference-odt.

Note that not all changes to the reference.odt (or reference.docx) will be significant.  You need to modify the styles that are used by pandoc for the various elements.

In the case of reference.docx, that would be the paragraph styles Normal, Title, Authors, Date, Heading 1, Heading 2, ..., Heading 5, Block Quote, Definition Term, Definition, Body Text, Table Caption, Picture Caption; and the character styles Default Paragraph Font, Body Text Char, Verbatim Char, Footnote Reference, Hyperlink.

John


Re: Reference file for docx? Carl Boettiger 4/20/12 9:17 AM
I have been using --reference-odt=reference.odt, so I think that should work?

I took a look at the styles.xml of both docx and odt.  Seems there's a "Source Code" style for code blocks as well in docx?  
I must be doing something wrong though.  I edit the styles.xml by hand in for the reference.docx file (zip archive).  I then use pandoc with --reference-docx=reference.docx but I get output that is still unchanged.  I can check the styles.xml of this output file, and indeed it has reverted to the default styles.xml.  somehow my reference file is being ignored entirely.  

-Carl



--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To view this discussion on the web visit https://groups.google.com/d/msg/pandoc-discuss/-/juiH_gEJivMJ.

To post to this group, send email to pandoc-...@googlegroups.com.
To unsubscribe from this group, send email to pandoc-discus...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pandoc-discuss?hl=en.



--
Carl Boettiger
UC Davis
http://www.carlboettiger.info/

Re: Reference file for docx? fiddlosopher 4/20/12 10:25 AM
+++ Carl Boettiger [Apr 20 12 09:17 ]:

>    I have been using --reference-odt=reference.odt, so I think that should
>    work?
>
>    I took a look at the styles.xml of both docx and odt. Seems there's a
>    "Source Code" style for code blocks as well in docx?
>
>    I must be doing something wrong though. I edit the styles.xml by hand
>    in for the reference.docx file (zip archive). I then use pandoc with
>    --reference-docx=reference.docx but I get output that is still
>    unchanged. I can check the styles.xml of this output file, and indeed
>    it has reverted to the default styles.xml. somehow my reference file is
>    being ignored entirely.

You can try unpacking the output docx file and looking to see if the
style changes you made in the reference.docx have been incorporated
there.  If they have, then maybe you just didn't make the right changes.

Unless you know ooxml well, it's probably easier to use Word to
edit the styles in your reference.docx.

Re: Reference file for docx? Carl Boettiger 4/20/12 2:46 PM
I did look at the resulting output xml after editing the xml of the input reference, and it did not match the input reference.  Instead, it was the default output xml as if no input reference had been specified.  Editing and saving the docx reference file in libreoffice directly also does not change the output. In each case, the behavior of pandoc is identical to if I had never specified a reference-docx or reference-odt.  Not sure what's going on here.  Perhaps if someone had a reference.docx or reference.odt modified to be different from the default that they've used before I could test it out and see if I get the modified format?

-Carl


--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To post to this group, send email to pandoc-...@googlegroups.com.
To unsubscribe from this group, send email to pandoc-discus...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pandoc-discuss?hl=en.

Re: Reference file for docx? fiddlosopher 4/21/12 9:01 AM
I'm attaching an example that works for me -- my.docx.
This simply changes the default font to Bitstream Vera Sans 18 pt.

My guess is that you're introducing errors into the style.xml file,
which are silently ignored.  (I need to improve error reporting in
the writer.)  It's best if you can get hold of a copy of Word, make
changes there, and inspect the resulting style.xml.

John

+++ Carl Boettiger [Apr 20 12 14:46 ]:


>    I did look at the resulting output xml after editing the xml of the
>    input reference, and it did not match the input reference. Instead, it
>    was the default output xml as if no input reference had been specified.
>    Editing and saving the docx reference file in libreoffice directly also
>    does not change the output. In each case, the behavior of pandoc is
>    identical to if I had never specified a reference-docx or
>    reference-odt. Not sure what's going on here. Perhaps if someone had a
>    reference.docx or reference.odt modified to be different from the
>    default that they've used before I could test it out and see if I get
>    themodifiedformat?
>    -Carl
>
>    On Fri, Apr 20, 2012 at 10:25 AM, John MacFarlane
>    <[1]fiddlo...@gmail.com> wrote:
>
>      +++ Carl Boettiger [Apr 20 12 09:17 ]:
>
>    > I have been using --reference-odt=reference.odt, so I think that
>    should
>    > work?
>    >
>    > I took a look at the styles.xml of both docx and odt. Seems there's a
>    > "Source Code" style for code blocks as well in docx?
>    >
>    > I must be doing something wrong though. I edit the styles.xml by hand
>    > in for the reference.docx file (zip archive). I then use pandoc with
>    > --reference-docx=reference.docx but I get output that is still
>    > unchanged. I can check the styles.xml of this output file, and indeed
>    > it has reverted to the default styles.xml. somehow my reference file
>    is
>    > being ignored entirely.
>
>      You can try unpacking the output docx file and looking to see if the
>      style changes you made in the reference.docx have been incorporated
>      there. If they have, then maybe you just didn't make the right
>      changes.
>      Unless you know ooxml well, it's probably easier to use Word to
>      edit the styles in your reference.docx.
>
>    --
>    You received this message because you are subscribed to the Google
>    Groups "pandoc-discuss" group.
>
>    To post to this group, send email to
>    [2]pandoc-...@googlegroups.com.

>    To unsubscribe from this group, send email to
>    [3]pandoc-discuss+unsubscribe@googlegroups.com.

>    For more options, visit this group at
>    [4]http://groups.google.com/group/pandoc-discuss?hl=en.

>
>    --
>    Carl Boettiger
>    UC Davis
>    [5]http://www.carlboettiger.info/

>
>    --
>    You received this message because you are subscribed to the Google
>    Groups "pandoc-discuss" group.
>    To post to this group, send email to pandoc-...@googlegroups.com.
>    To unsubscribe from this group, send email to
>    pandoc-discus...@googlegroups.com.
>    For more options, visit this group at
>    http://groups.google.com/group/pandoc-discuss?hl=en.
>
> References
>
>    1. mailto:fiddlo...@gmail.com
>    2. mailto:pandoc-...@googlegroups.com
>    3. mailto:pandoc-discuss%2Bunsubscribe@googlegroups.com
>    4. http://groups.google.com/group/pandoc-discuss?hl=en
>    5. http://www.carlboettiger.info/

Re: Reference file for docx? Carl Boettiger 4/24/12 10:24 AM
Excellent, thanks John, that file works.  I'm not sure why the odt format does not work when I create the odt document from pandoc, edit it in libreoffice, and use that as the reference.odt.   Surely I shouldn't need MS Word to get the odt version of reference working?  Perhaps I am still doing something wrong. Very puzzling. 

Carlhttp://www.carlboettiger.info/