1

When using the org's ox-koma-letter, I'm having a problem with org exporting LaTeX commands expanding the leading \ as $\backslash$.

Using the example letter (from Romeo to Juliet) on the orgmode.org site, if I change the closing section as follows:

* Yours truly,                                                      :closing:
#+LaTeX: \hspace{2em}  
Romeo of House Montague

But org's export to LaTeX is expanding the line with the \hspace{2em} command as:

\setkomavar{signature}{$\backslash$hspace\{2em\} Romeo of House Montague}

How do I prevent this?

[edited to specify precise environment in which issue is occurring.]

[edit 2: As of 20180702, the org-koma-letter Signature definition in org-contrib is:

 ;; Signature.
 (let* ((heading-val
     (and (plist-get info :with-headline-opening)
      (org-string-nw-p
       (org-trim
        (org-export-data
         (org-koma-letter--get-tagged-contents 'closing)
         info)))))
    (signature (org-string-nw-p (plist-get info :signature)))
    (signature-scope (funcall check-scope 'signature)))
   (and (or (and signature signature-scope)
    heading-val)
    (not (and (eq scope 'global) heading-val))
    (format "\\setkomavar{signature}{%s}\n"
        (if signature-scope signature heading-val))))

Which still produces the same issue. ]

  • 1
    Does not happen with emacs-version 26.1 and org-version 9.1.6. What versions of emacs and org-mode do you have? Does the same problem occur with emacs -Q? – Tobias Jun 23 '18 at 8:49
  • I've edited the question above with more detail. I've just tried it with emacs -Q just adding the ox-koma-letter export code, and I get the same behaviour. I'm using emacs 26.1 and org-version 9.1.9. – emacsomancer Jun 23 '18 at 16:33
2

As a workaround you can replace the Section ;; Signature in function org-koma-letter--build-settings with the following code. I essentially removed org-export-data from there.

 ;; Signature.
 (let* ((heading-val
     (and (plist-get info :with-headline-opening)
      (org-string-nw-p
       (org-trim
        ;; (org-export-data
         (or (org-koma-letter--get-tagged-contents 'closing) "")
        ;; info)
                ))))
    (signature (org-string-nw-p (plist-get info :signature)))
    (signature-scope (funcall check-scope 'signature)))
   (and (or (and signature signature-scope)
    heading-val)
    (not (and (eq scope 'global) heading-val))
    (format "\\setkomavar{signature}{%s}\n"
        (if signature-scope signature heading-val))))

They use the translator for the headlines org-koma-letter-headline to extract the :opening: headline and put its stuff into org-koma-letter-special-contents. org-koma-letter--get-tagged-contents retrieves the opening from there. I have the impression that org-koma-letter-headline already gets the translated headline contents and translating it again with org-export-data is a bad idea.

  • Is there a good way of doing this (i.e. replacing the Signature bit) without just editing the org-koma-letter file itself? E.g. of programmatically replacing it in .emacs? – emacsomancer Jun 23 '18 at 19:50
  • 1
    @emacsomancer I've already posted a bug report and the problem is already fixed in the development version of orgmode. ... Should be available via melpa very soon. – Tobias Jun 23 '18 at 22:31
  • Cheers! I'll just wait for the fix to come down via Melpa. – emacsomancer Jun 24 '18 at 1:11
  • 1
    @emacsomancer Nicolas Goaziou notified me about a small problem in his answer to my buf-fix proposal. The case when org-koma-letter--get-tagged-contents must be handled separately. I've corrected the above bugfix in that regard. I've tested the corrected version with org files containing a :closing: and org files not containing any :closing:. Looks like it runs flawless. – Tobias Jun 24 '18 at 10:39
  • I've noticed that as of org-contrib of 20180702, the signature bit in org-koma-letter still has error-producing org-export-data lines included (see OP edit). I assumed the fix would have rolled out by now. – emacsomancer Jul 2 '18 at 23:18

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.