TeX - LaTeX Asked by muzzle on January 28, 2021
I am trying to setup LyX to export directly to the reStructuredText format. I adapted these instructions just replacing markdown with reStructuredText.
Unfortunately LyX changes the path of every image. Here is a short example.
e.g. this figure
.. figure:: 0_home_muzzle_Nextcloud_Stuff_Stuff_documentation_source_img_pressure.jpg
:alt: Pressure
:width: 80.0%
Pressure
should be
.. figure:: img/pressure.jpg
:alt: Pressure
:width: 80.0%
Pressure
LyX replaces the image path with that of the copy of the image created to allow the converter to do its job. This is the correct behavior if the output format will somehow embed the image in the document, but that is not the case for reStructuredText (or for markdown, for that matter).
If I export the lyx file as latex from the GUI, and then convert it to reStructuredText using the command
pandoc --wrap=none -f latex -t rst -o file.rst file.tex
the image path is correct, is there a way to obtain the same effect from the UI conversion and export system?
Btw, someone had a similar issue 5 years ago, but it does not look like it was ever properly solved.
Thanks @fran for the hint, exporting the final version of the file (by adding the nice
flag to the export command) helped. Unfortunately this causes lyx to remove the image extension from the filename.
The best workaround I have found to this is to manually specify the image extension in the conversion command:
pandoc --wrap=none -s --default-image-extension=jpg -f latex -t rst -o $$o $$i
Unfortunately this means that you have to convert all your images int one format. This is not an ideal solution and I hope someone comes up with a better one.
In any case if you want to automate the process you can create a new converter in the LyX GUI.
Navigate to Tools > Preferences > File Handling > File Formats
and add the rst format.
The go to Tools > Preferences > File Handling > Converters
and create the converter using the command above and the Extra flag nice
.
Answered by muzzle on January 28, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP