Code Monkey home page Code Monkey logo

phd_template's Introduction

Template of Mathias Sablé-Meyer's Ph.D. Manuscript

Warning

The scripts here are provided as is. They worked for me but are far from polished. Things are brittle and may fail on ill-formed input — and what "well-formed" means here is at best loosely specified below.
Expect to have to dig into some of the scripts, templates, etc.

This is a collection of scripts I wrote in order to satisfy following constraints:

  1. Write the text in Microsoft Word (don't ask why)
    1. Without having the figures in there because it becomes laggy after a little while
    2. With the references in there, handled by zotero
  2. Have the best of LaTeX typesetting to generate an acceptable .pdf

You can take a look at what my own manuscript looks like, and from afar:

mosaic of the first pages of Mathias Sablé-Meyer's Ph.D.

It relies heavily on pandoc to perform the .docx -> .tex translation, together with a souped-up template I needed. On top of this, a few panflute scripts work on pandoc's AST to be able to insert figures where needed, format tables better, handle references to figures in a LaTeX way, and a few other things.

Then XeLaTeX performs the final compilation step, and just because my doctoral school required a specific template for the front and the back, pdftk makes a few page changes.

In order for this to work you need some version of pandoc (all I can say is, it works on 2.19.2) and some version of python and panflute (worked on python=3.10, panflute=2.2.3), as well as xelatex and a few basic Unix tools (make, sed, pdftk).

What to expect

Paragraphs starting with #FIGUREXXlabel_float# caption will turn into inserting a float with the figure ./media/figure-XX.pdf with the label label, a size equal to float*pagewidth, and the rest of the paragraph as a caption. Throughout the rest of the document, inserting \ref{label} will be replaced with Figure YY in bold and in the color of the chapter, where YY is the number generated by LaTeX, e.g. 2.3 if this is the third figure of chapter 2.

The same holds for tables, but the caption needs to be above, look like #TABLElabel_fontsize# caption where fontsize is a valid LaTeX font size, and you can reference them with \ref{table:label}

Code works as you expect: if a paragraph has style SourceCode in word, and starts with a language name like python and a new line, then it will be correctly turned into a code block with syntax highlight in LaTeX.

A paragraph starting with #ABSTRACT# will turn into a coloured box with the right color.

Finally, quotes from the .docx file will be turned into LaTeX's epigraphs. The script that does this assumes that the quote ends with a long dash followed by the author reference.

References

A note on references :

Zotero inserts references in the document, and I could just format them without caring about parsing them as references, having a .bib file, etc.

With that said, it makes references unclickable, and is conceptually a bit sad, since everything else is converted with at least some level of semantic information. I wrote a small script to clean up references formatted by zotero in a .docx file, left as fix_ref.py: using this one can modify the makefile to include:

# [...]
PhD.pdf: $(SOURCES) ./media/figure-1.pdf headers.yaml
	python fix_ref.py $(SOURCES) tmp.docx
	pandoc tmp.docx --from docx+citations --citeproc -o bib.bib
	pandoc tmp.docx \
		--[...] \
		--reference-links \
		--reference-location=block \
		--citeproc \
		--natbib \
		--bibliography=bib.bib \
		--[...]
		--[...]
  rm tmp.docx

This somewhat works, but placing the references at the right location (amongst other things) proved too hard, so I ended up not going on with this. I am, however, using it to generate a html version of my Ph.D.

phd_template's People

Contributors

mathias-sm avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.