CLAWRIM Wiki

The Computational Lab for Advanced Water Resources Informatics and Modeling

User Tools

Site Tools


howtos:how_to_convert_latex_to_qmd

How to convert LaTeX to QMD

# convert tex to tempory qmd
pandoc main.tex --to=markdown+tex_math_dollars+raw_tex --wrap=none -o main.tmp
 
# extract citations
grep -oE '@\{[^}]+\}|@[A-Za-z0-9_:/.-]+' main.tmp |
  sed 's/[@{}]//g; s/^/\\citation{/; s/$/}/' |
  sort -u > refs.keys
 
# extract cited bib entries only
bibtool -x refs.keys --preserve.key.case=on -i full.bib -o references.bib
 
# add yaml header
(cat<<'EOT'
---
title: "TITLE"
format:
  html:
    toc: true
    number-sections: true
  pdf:
    toc: true
    number-sections: true
bibliography: references.bib
---
 
EOT
cat main.tmp) > main.qmd
 
# delete tmp file
rm main.tmp
 
# render
quarto render main.qmd --to pdf
howtos/how_to_convert_latex_to_qmd.txt · Last modified: by hcho

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki