Re: Macro: exporting roman numerals formatted as small-caps

2022-12-09 Thread Christian Moe


Max Nikulin writes:

> On 08/12/2022 19:38, Carlos Martínez wrote:
>> #+MACRO: sc (eval (if (org-export-derived-backend-p
>> org-export-current-backend 'latex) (concat "@@latex:\\textsc{@@" $1
>> "@@latex:}@@") (concat "@@odt:> text:style-name=\"T1\">@@"$1"@@odt:@@")))
>
>^  ^
> Your missed spaces around $1, but it is unlikely a problem.
>
> Disclaimer: I know almost nothing about odt. Have you customized ODT
> styles? I do not see "T1" in etc/styles/OrgOdtStyles.xml
>
> info "(org) Advanced topics in ODT export"
> https://orgmode.org/manual/Advanced-topics-in-ODT-export.html

Indeed. Carlos, I'm guessing that you formatted a Roman numeral in ODT
as you wanted it to look, saved the document, opened content.xml and
used the resulting XML.

However, what happens then is that the formatting gets saved as an
automatically numbered text style "T1", which isn't going to mean the
same thing the next time you export a document.

See if this works:

- In the document you are using as your ODT_STYLES_FILE, type a Roman
  numeral and format it the way you like.

- Then make it a named character style. In LibreOffice, open the "Styles
  and formatting" sidebar and select the "Character styles" tab. Select
  the formatted Roman numeral in the text. From the "Styles actions"
  dropdown (top right in "Styles and formatting"), choose "New style
  from selection". Give it a name, e.g. "Roman numeral".

- Save the styles file.

- In your macro: replace "T1" with "Roman numeral".

- In all your Org documents where you want this to work: make sure that
  (1) the macro is defined and (2) that ODT_STYLES_FILE points to the
  file you have saved with the style definition for "Roman numeral".

There isn't any simpler way to do it, due to the way LibreOffice stores
all local formatting as generated styles.

Yours,
Christian



Re: Macro: exporting roman numerals formatted as small-caps

2022-12-08 Thread Max Nikulin

On 08/12/2022 19:38, Carlos Martínez wrote:


#+MACRO: sc (eval (if (org-export-derived-backend-p
org-export-current-backend 'latex) (concat "@@latex:\\textsc{@@" $1
"@@latex:}@@") (concat "@@odt:@@"$1"@@odt:@@")))


   ^  ^
Your missed spaces around $1, but it is unlikely a problem.

Disclaimer: I know almost nothing about odt. Have you customized ODT 
styles? I do not see "T1" in etc/styles/OrgOdtStyles.xml


info "(org) Advanced topics in ODT export"
https://orgmode.org/manual/Advanced-topics-in-ODT-export.html


I want to achieve something like this: "When exporting to LaTeX (o
derived formats), surround the argument with \textsc{}; if any other
format [it will always be odt], do the same with the proper odt code.


I recommend fallback to the argument as plain text for other backends:

(cond
 ((org-export-derived-backend-p org-export-current-backend 'latex)
  (concat ; or format
  ))
 ((org-export-derived-backend-p org-export-current-backend 'odt)
  ; ...
  ))
 (t $1))

If you are absolutely sure that you will never export the file to ascii 
or html then no `eval' is necessary


#+MACRO: sc @@latex:\textsc{$1}odt:text:style-name="T1">$1@@


Here I assume that macro argument contains no markup and can be safely 
put inside export snippets. Otherwise a bit longer version closer to 
`concat' arguments in your original variant would be better.


Another point is the name. Small caps as "sc" means direct formatting. A 
name based on "roman number" might be better. If some other objects 
should be formatted as small caps then creating another macro might help 
to change styles independently later.




Macro: exporting roman numerals formatted as small-caps

2022-12-08 Thread Carlos Martínez
Hello everyone!,
I am working in a paper written in org mode. There are lots of roman
numerals referring to centuries. In Spanish, those are written in
roman numerals and small caps. I want to export my paper both to odt
and to LaTeX.

I found a macro by Juan Manuel Macías which helped me to export the
numerals surrounded by \textsc{} when exporting to pdf, but I struggle
to do the same when exporting to odt. This is the macro:

#+MACRO: sc (eval (if (org-export-derived-backend-p
org-export-current-backend 'latex) (concat "@@latex:\\textsc{@@" $1
"@@latex:}@@") (concat "@@odt:@@"$1"@@odt:@@")))

I want to achieve something like this: "When exporting to LaTeX (o
derived formats), surround the argument with \textsc{}; if any other
format [it will always be odt], do the same with the proper odt code.

Thanks everyone, and my apologies if this is a noob question (but I am
actually a noob).
Best regards
N.B.: I extracted the odt snippet looking at the contents.xml inside
the odt file.