jkitchin / scimax

An emacs starterkit for scientists and engineers
Other
1.04k stars 123 forks source link

Custom export template to use with ox-pandoc #509

Open zenny opened 4 days ago

zenny commented 4 days ago

Hi @jkitchin,

The addition of ox-pandoc made a breeze. But I am finding it difficulty to figure out how to use a specific built-on scimax template or any custom template like kaobook - tufte-inspired book template to export the files to pdf?

I am having some issues with the export despite I specify LaTeX headers in a proper format like

#+LaTeX_Header: \usepackage{junicode}
#+OPTIONS: timestamp:nil toc:nil
#+BEGIN_EXPORT latex
   \clearpage \setcounter{tocdepth}{5} \tableofcontents \clearpage
#+END_EXPORT

It neither respects the font directive nor ToC directive. No ToC is produced.

I went with ox-pandoc instead of 'C-c C-e l o) because it is frustratingly difficult to autofit long sentences to a column of a table (already clarified in https://github.com/jkitchin/scimax/issues/377) with the latter at least in my experience.

Cheers and have a nice weekend.

/zenny

jkitchin commented 2 days ago

Your example works fine for me. I guess you need to see what errors come up when you build your file to pdf. Sometimes the best way to do that is export the org file to latex first. Then read that, see what it is produced.

Then, manually build the file in a shell with your latex. see what errors are produced. there could be missing packages, incompatible packages, etc. If it doesn't work here, it can't work from emacs + orgmode.

zenny commented 2 days ago

Your example works fine for me. I guess you need to see what errors come up when you build your file to pdf. Sometimes the best way to do that is export the org file to latex first. Then read that, see what it is produced.

Then, manually build the file in a shell with your latex. see what errors are produced. there could be missing packages, incompatible packages, etc. If it doesn't work here, it can't work from emacs + orgmode.

Thanks @jkitchin

I tried with scimax and ews emacs-configs to export pdf via default ox-export-to-pdf (C-c C-e l o) and ox-pandoc (C-c C-e p 5) and the results are as follows, the headers remained the same for all:

In default scimax configuration with C-c C-e l o, the fonts rendered are alright, but it does not cover a separate cover page (1st page) and the tables ran out of the page on the right and the numbering is still not rendered in junicode font:

pic-selected-241110-2121-00

With scimax ox-pandoc export, the same page looks as follow with table contents justified, but do not adhere to the font directive:

pic-selected-241110-2120-00

The ToC produced by ox-export-to-pdf EWS looks: pic-selected-241110-2121-45

which is compact than the one produced in scimax (org-export-to-pdf) as follows which I prefer to be honest:

pic-selected-241110-2123-49

Just wondering how to generate a document that adheres to the font directive, autoformat tables as in ox-pandoc to html5 pdf, produces a genuine ToC as in scimax and add a cover page based on TITLE, SUBTITLE, AUTHOR, DATE, and insert some footers or headers based on TITLE and SECTION as in kaobook/tufte format.!!!???

Cheers, /zenny

jkitchin commented 1 day ago

You are mixing and matching things here hoping to get what you want. Instead, you should pick an approach, and it is almost certainly latex that you want. What you want is not that simple, with a bunch of moving parts. That is going to require you to learn more about latex, and then how org is converted to latex.

The only path I see is you pick one feature at a time, work it out, and then add to it. First I would get the kaobook/tufte format working for a simple document, then add the title page and table of contents. Probably that is just \maketitle and \tableofcontents. then see about the font, then see about the tables.

zenny commented 1 day ago

You are mixing and matching things here hoping to get what you want.

Btw, both scimax and ews configs are not mixed, they are run by as vanilla as upstream with emacs --init-directory=./scimax and emacs --init-directory=./ews` separately.

Instead, you should pick an approach, and it is almost certainly latex that you want. Even with vanilla scimax without any changes made and as seen in the table of contents above, the page numbers were rendered in two different fonts - lmodern and junicode mix.

What you want is not that simple, with a bunch of moving parts. That is going to require you to learn more about latex, and then how org is converted to latex.

Certainly, I shall follow your advice.

The only path I see is you pick one feature at a time, work it out, and then add to it.

My first goal is to get a uniform formatting of documents using vanilla scimax, fyi.

First I would get the kaobook/tufte format working for a simple document, then add the title page and table of contents. This is secondary once the first goal is achieved by producing uniformly-formated documents with desired fonts.

Probably that is just \maketitle and \tableofcontents. then see about the font, then see about the tables.

Thanks for the pointers, I shall try to have a look.

Cheers, /zenny

jkitchin commented 1 day ago

You are mixing and matching things here hoping to get what you want.

Btw, both scimax and ews configs are not mixed, they are run by as vanilla as upstream with emacs --init-directory=./scimax and emacs --init-directory=./ews` separately.

I mean mixed in the sense that you tried three different things to see if you get what you want, but you can't easily take features from ox-pandoc and combine it with the other approaches. they use different mechanisms to get to a pdf.

Instead, you should pick an approach, and it is almost certainly latex that you want. Even with vanilla scimax without any changes made and as seen in the table of contents above, the page numbers were rendered in two different fonts - lmodern and junicode mix.

Solving issues like this is done in LaTeX, see for example, https://tex.stackexchange.com/questions/29650/font-style-for-page-number-for-chapter-in-toc or more generally a google search like "latex table of contents page numbers are in different font". I know that is an annoying answer, but it is the only way I know to solve things like this. maybe tools like chatgpt are useful these days too.

for complicated things like this, I find I usually have to go back and forth between emacs and the shell to see what is happening, e.g. if there are error messages, conflicting packages, etc.

What you want is not that simple, with a bunch of moving parts. That is going to require you to learn more about latex, and then how org is converted to latex.

Certainly, I shall follow your advice.

The only path I see is you pick one feature at a time, work it out, and then add to it.

My first goal is to get a uniform formatting of documents using vanilla scimax, fyi.

this should be framed as what latex settings are required to get what you want, and then, how do you get org-mode (via scimax) to generate those settings. Maybe it is just using the right packages, but it might also require the right configuration in the header too.

First I would get the kaobook/tufte format working for a simple document, then add the title page and table of contents. This is secondary once the first goal is achieved by producing uniformly-formated documents with desired fonts.

Probably that is just \maketitle and \tableofcontents. then see about the font, then see about the tables.

Thanks for the pointers, I shall try to have a look.

Cheers, /zenny

Good luck!

zenny commented 1 day ago

You are mixing and matching things here hoping to get what you want.

Btw, both scimax and ews configs are not mixed, they are run by as vanilla as upstream with emacs --init-directory=./scimax and emacs --init-directory=./ews` separately.

I mean mixed in the sense that you tried three different things to see if you get what you want, but you can't easily take features from ox-pandoc and combine it with the other approaches. they use different mechanisms to get to a pdf.

Instead, you should pick an approach, and it is almost certainly latex that you want. Even with vanilla scimax without any changes made and as seen in the table of contents above, the page numbers were rendered in two different fonts - lmodern and junicode mix.

Solving issues like this is done in LaTeX, see for example, https://tex.stackexchange.com/questions/29650/font-style-for-page-number-for-chapter-in-toc or more generally a google search like "latex table of contents page numbers are in different font". I know that is an annoying answer, but it is the only way I know to solve things like this. maybe tools like chatgpt are useful these days too.

Thanks for your pointers. I shall have a look.

for complicated things like this, I find I usually have to go back and forth between emacs and the shell to see what is happening, e.g. if there are error messages, conflicting packages, etc.

What you want is not that simple, with a bunch of moving parts. That is going to require you to learn more about latex, and then how org is converted to latex.

Certainly, I shall follow your advice.

The only path I see is you pick one feature at a time, work it out, and then add to it.

My first goal is to get a uniform formatting of documents using vanilla scimax, fyi.

this should be framed as what latex settings are required to get what you want, and then, how do you get org-mode (via scimax) to generate those settings. Maybe it is just using the right packages, but it might also require the right configuration in the header too.

Would you mind sharing the headers you use to produce consistent font rendering and managing tables inside org-mode documents? It would be immensely useful to begin with, imho.

First I would get the kaobook/tufte format working for a simple document, then add the title page and table of contents. This is secondary once the first goal is achieved by producing uniformly-formated documents with desired fonts.

Probably that is just \maketitle and \tableofcontents. then see about the font, then see about the tables.

Thanks for the pointers, I shall try to have a look. Cheers, /zenny

Good luck!

jkitchin commented 7 minutes ago

I don't have any headers like that. I typically try to avoid these kinds of customizations.

See https://en.wikibooks.org/wiki/LaTeX/Tables for many options on formatting tables.