0

I can get the desired result

consumable1........................................month/year

consumable2........................................month/year

consumable3........................................month/year

consumable4........................................month/year

into a latex export by replacing the dots with the \dotfill command in org-mode. However, the command is not recognized by the ODT export org-mode option, and I was wondering if there is a workaround? This is why I hate having to work with people that only use word :-(. Thanks in advance for any help.

Update:

The solution should also be able to cope with strings with different lengths. For example:

apple..................................month/year

banana..................................month/year

pear..................................month/year

is not ok, because it does not create the correct amount of dots in each line, so that the dates are all right aligned.

  • 1
    In what context do you want this to happen? Lists? Tables? Some of them? All of them? It would help I think to specify the context more exactly. – NickD Mar 11 at 17:26
  • Thank you for your feedback. No particular context. Just within a block of text, (for example, below a section header). However, I think the community might be interested in doing it inside the other environments. – Andre Mar 11 at 20:32
  • Would a workaround be to export to latex then pandoc to docx? That's what I typically do to get a docx version for colleagues as ODT never comes out right for me. – jdtonkin Mar 11 at 22:40
  • Does ODT provide that facility? All that org can do is provide an interface to the underlying backend facility: it cannot implement it. LaTeX provides it, but maybe ODT does not. – NickD Mar 12 at 12:05
  • According to this post it can be done in open office with a tab stop filled with dots forum.openoffice.org/en/forum/viewtopic.php?f=7&t=67171 – Andre Mar 12 at 12:09
1

You could use macro replacement:

#+MACRO: dotfill (eval (if (org-export-derived-backend-p org-export-current-backend 'odt) (make-string 40 ?.) "\\dotfill"))

consumable1 {{{dotfill}}} month/year


If you need alignment you may have to embed raw OpenDocument XML:

#+begin_export odt
<text:p text:style-name="Contents_20_1"> apple <text:tab/> month/year </text:p>
<text:p text:style-name="Contents_20_1"> banana <text:tab/> month/year </text:p>
<text:p text:style-name="Contents_20_1"> pear <text:tab/> month/year </text:p>
#+end_export

Alternatively, you could wrap the text inside an example block, select the text and do M-x align-regexp \. RET.

#+begin_example
apple  ..................................month/year
banana ..................................month/year
pear   ..................................month/year
#+end_example

If you have specific requirements for styling your odt document, you can copy the file org-mode/etc/styles/OrgOdtStyles.xml elsewhere and add the following style under <office:styles>:

<!-- dotfill -->
   <style:style style:name="DotFill" style:family="paragraph" style:parent-style-name="Standard">
     <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false">
       <style:tab-stops>
     <style:tab-stop style:position="9.999cm" style:leader-style="dotted" style:leader-text="."/>
       </style:tab-stops>
     </style:paragraph-properties>
   </style:style>

You should then reference that file in the Org document:

#+ODT_STYLES_FILE: "/path/to/mystyles.xml"

And apply the style:

#+ODT: <text:p text:style-name="DotFill"> apple <text:tab/> month/year </text:p>

  • This is great. But if the strings at the begining of the lines or the dates at the end are different in length, it won't give the desired output in the exported odt file. Please see my updated question. – Andre Mar 12 at 8:56
  • I see. I updated the answer. – jagrg Mar 12 at 22:48
  • Thanks. For this to work, I think I need to add something to the styles XML file? I have tried to add the source code block that you wrote but it outputs it as it is. – Andre Mar 14 at 21:14
  • I copied the code from org-mode/etc/styles/OrgOdtStyles.xml so I'm not sure why it didn't work for you. In any case, I edited the answer and I hope someone comes up with an easier solution :) See here and here. – jagrg Mar 15 at 12:35
  • Thank you very much. After reinstalling org-mode it worked. I had to create two source blocks, one for latex and another one for odt for them to work independently and without interferences. Thankfully I didn't have to mess around with the xml files. – Andre Mar 15 at 17:44
1

Add dotted line in org-mode for export to latex and ODT

Author of the ODT backend here.

Let me address the ODT part of the question.

The answer assumes that you are using the enhanced ODT exporter (and not the old exporter available with stock Emacs or Orgmode).

For the impatient, the enhanced ODT backend can be installed by adding https://kjambunathan.github.io/elpa/ to package-archives. You can learn more about the enhanced ODT exporter by visiting the Github repo The Authoritative fork of Org mode's ODT exporter.


The verse environment in the ODT exporter preserves tab. Once you can sneak in a tab, it is a matter of adjusting the paragraph style to have the tabs spaced and filled according to your needs.

Add dotted line in org-mode for export to ODT

For quick start, download dottedfill.zip

To get

Screenshot from 2019-03-15 10-37-45

use the snippet that I enclose below.

Some comments on the snippet

  1. Note the the verse block below has a tab and not spaces
  2. The Text_20_body styles uses the following settings

Screenshot from 2019-03-15 10-38-10

#+OPTIONS: author:nil date:nil

#+TITLE: Dotted Fill using Verse blocks and Custom Paragraph Styles

#+ODT_EXTRA_STYLES: <style:style style:name="Text_20_body" style:display-name="Text body" style:family="paragraph" style:parent-style-name="Standard" style:class="text">
#+ODT_EXTRA_STYLES:  <style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0.212cm" loext:contextual-spacing="false">
#+ODT_EXTRA_STYLES:   <style:tab-stops>
#+ODT_EXTRA_STYLES:    <style:tab-stop style:position="0cm"/>
#+ODT_EXTRA_STYLES:    <style:tab-stop style:position="9.999cm" style:leader-style="dotted" style:leader-text="."/>
#+ODT_EXTRA_STYLES:   </style:tab-stops>
#+ODT_EXTRA_STYLES:  </style:paragraph-properties>
#+ODT_EXTRA_STYLES: </style:style>

#+ATTR_ODT: :style "Text_20_body"
#+begin_verse
apple   month/year

banana  month/year

pear    month/year
#+end_verse

I have archived a copy of this reply at Add dotted line in org-mode for export to ODT · Issue #54 · kjambunathan/org-mode-ox-odt.

  • This looks good assuming it works. Could you also include the \dotfill command to make it work with latex? – jagrg Mar 15 at 12:39
  • Thank you. I didn't try this solution. Possibly it will be helpful to someone else. Sorry for not trying it out but I don't want to install new things at this point, specially if it has to do with org-mode. – Andre Mar 15 at 17:49

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.