connorferster / handcalcs

Python library for converting Python calculations into rendered latex.
Apache License 2.0
5.69k stars 434 forks source link

Convert rendered equations into MS word #222

Open deparser opened 1 month ago

deparser commented 1 month ago

I’m looking to convert Jupyter notebooks with calculations rendered by handcalcs into MS Word equations. So far, I’ve been following these steps:

  1. Display the math as MathML using MathJax.
  2. Copy and paste it into Notepad++ to strip formatting.
  3. Copy it again and paste it into Word.

However, I’m encountering some issues. The formatting, particularly the column indentation and text height (like varying font sizes in handcalcs-rendered equations), doesn’t transfer well. The result looks quite different from the original.

Has anyone else faced this issue, or found a more reliable process to maintain the formatting when converting equations?

The goal is to automate the conversion of the jupyter notebook to doc file.

PascalGitz commented 4 weeks ago

Hey, let me introduce you to Quarto. This is the perfect solution for this. Quarto translates Markdown into latex, html or word. After following the installation instructions you can create a jupyter notebook like so:

grafik The first cell does all the formatting for the word export. You can also add a custom template (from your company for example). In this example i disabled the code input cells, so only the celloutput will be in the export.

For handcalcs, I did change the latex_block_start and end, that it follows the markdown syntax (you can also change this in your config file in your handcalcs installation).

The whole Notebook can then be exported to a .docx file, which looks like this:

grafik

Or with one button you can export the notebook to a pdf via latex, looking like this:

grafik

Greetings from another structural engineer :)