As I graduated from LaTeX with GitHub, Docker and TravisCI

    Since the time of studying at the university, I used LaTeX for laboratory and coursework. I met LaTeX for the first time on Coursera, on the course " Documents and presentations in LaTeX ".


    In this post I will tell you how I wrote a diploma with LaTeX and why I used GitHub, Docker and TravisCI.


    But why?


    Foreword


    My way of editing and creating documents began with Microsoft Word, probably like many. After switching from Windows to Linux, I easily began using OpenOffice first, and then LibreOffice, which in my tasks was not inferior in Word functionality.


    It was a little pain when writing some essay in the library's computer room in OpenOffice, you carry it on a printout to the admin computer with Microsoft Word, and all the formatting flies away. At that school time, no one explained to me that it was possible to save a document in PDF and print without problems, I already learned this myself when I was studying at the university and I had to print documents almost every day.


    Back to LaTeX, before using it, all I heard about LaTeX is that it writes articles to scientific journals because it is very convenient for working with formulas. Those who think the same way, I recommend to watch the course on Coursera, maybe it will change your opinion, for example, I really liked it.


    Hello, World on LaTeX:


    \documentclass{article}\begin{document}
    Hello, World!
    \end{document}

    By the way, using LaTeX you can do presentations. Here here you can see many examples might look like this presentation.


    Bachelor Degree with LaTeX


    By the end of the third year I was already actively using LaTeX for processing almost all documents, it was decided to write with it a bachelor’s degree .


    At first, I used LaTeXila as an IDE, in which the project was built with one button, it was possible to enable spell checking, but I sometimes crashed and slowed it down, so I began to use Sublime Text along with the Makefile.


    Example Makefile:


    all: build run
    build:
        latexmk -xelatex -synctex=1 main.tex
    run:
        xreader main.pdf &
    clean:
        rm *.aux *.fdb_latexmk *.fls *.log *.out *.synctex.gz *.toc

    All sources stored in git, for convenience of collaboration with the supervisor used GitHub. The structure of the project was very simple; the main.texpreamble and the remaining chapters were stored in a file , which were stored in a separate directory.


    main.tex:


    \documentclass[a4paper,14pt]{extarticle}% 14й шрифт\input{inc/preamble}% Подключаем преамбулу\begin{document}\tableofcontents% Содержание \clearpage\input{inc/0-intro}% Введение\input{inc/1-pz}% Постановка задачи
    ...
    \input{inc/0-bibliography}% Библиографический список\input{inc/a-app}% Приложение А\input{inc/b-app}% Приложение Б\includepdf{act}% Подключение стороннего PDF-файла\end{document}

    The description of all styles and formatting is in the file preamble.texthat is connected at the very beginning of the document.


    It was very convenient not to care about formatting content, bibliography and other parts of the diploma.


    Content
    Content


    I will describe my advantages when working with LaTeX, compared with WYSIWYG editors:


    • convenient versioning (instead of diploma.odt , diploma_01.01.2015.odt , diploma_repl_pechat.odt - versioning in git and the ability to roll back to any commit)
    • by accidentally pressing something, the layout does not fly off (I have this happened)
    • flexible settings (which are not always available in WYSIWYG editors or they are not obvious)
    • homogeneous environment for everything (the source of the presentation is in the same repository as the diploma)
    • the possibility of collaboration (the diploma supervisor can look in the repository of what has changed since the last check)
    • convenient to use as a template for many different documents
    • It is convenient to include such inserts as source code for example or additional PDF files.

    Here is an example of how easily a source file can be included in a document:


    \lstinputlisting[numbers=left]{inc/ddos-deflate/ddos.sh}

    Linked source code to document
    Linked source code to document


    There is only one downside to using LaTeX for me - you need to take the time to polish everything to the desired result. I even for a moment wanted to be bothered to redraw all diagrams and diagrams in the native way using TikZ , but it took a lot of time, so I calmly used Google Drawings and draw.io.


    Having successfully defended a bachelor’s degree and gained some knowledge of working with git, GitHub, Makefile, and LaTeXStackExchange google in English, I forgot about the diploma for a couple of years in order to use my template to write my master’s degree.


    Master's degree


    At the time when I was studying in the magistracy, I already began to get involved in the tools of an engineer, such as Docker, began to practice with the tools of Continuous Integration, to learn the practices of DevOps. It was also interesting for me to beautifully draw up my pet-open-source projects with beautiful README files.


    In general, when I started to write a master's degree , the requirements for registration did not change much, so I took the template for my bachelor's degree and completed the little things, such as items such as a list of illustrative material, a list of abbreviations and so on. When defending a bachelor’s degree diploma, we used A1-sized posters, and in the master’s program we were already allowed to use slideshow presentations, so I also edited slides using LaTeX and beamer.


    Presented with LaTeX and beamer
    Presented with LaTeX and beamer


    Inspired by the concept of CI, I thought, why not collect a new PDF at each commit into the repository? Connecting GitHub to TravisCI took just a few minutes. Although TravisCI does not know how to work directly with LaTeX, it works great with Docker. Cool, I thought, I will kill several birds with one stone:


    • practice writing dockerfile
    • I'll migrate all the LaTeX packages to Docker (there are a lot of them and they are pretty heavy)
    • practice using TravisCI
    • I will help those who suddenly want to use my template on a different OS than Linux

    Writing a configuration file for TravisCI, Dockerfile and editing the Makefile didn’t take much time and was convenient.


    Part of the Makefile to run the project build in Docker:


    ...
    docker:
        docker build -t docker-latex .
        docker run -ti -v ${PWD}:/master-thesis:Z docker-latex bash -c "make build && make clean"
        docker run -ti -v ${PWD}:/master-thesis:Z docker-latex bash -c "make -C presentation && make -C presentation clean"

    Now the diploma supervisor could not just see my changes in the code, but also a detailed version of the document.


    Releases
    Releases


    Having received a diploma in the form necessary for myself, I decided to share the template with the community, by analogy with my bachelor. It was decided to beautifully issue the README file of the repository, because this is the face of the project. The person who found your project on the Internet should read the file README right away without any difficulty how to build the project and what to do with it.


    README.md file
    README.md file


    Soon I will have to write the third diploma and I think that my approach to writing it will not change at all and I will spend quite a tiny amount of time on its design. Given that I moved from Linux to Mac OS, the transition will be absolutely painless, as there is a Docker.


    Results


    The usual interest of LaTeX allowed me to dive a bit more into this area:


    • "got a hand" when working with LaTeX, which later helped save time when creating documents and presentations
    • Gained experience when working with git and github, while working with these pet projects
    • used to practice things like Docker and TravisCI, which gave me a good push when diving into DevOps
    • learned how to neatly arrange their pet projects

    Answers to potential questions


    Why do you store PDF files in the repository?

    Solely so that the person who entered the repository could not only see the source code, but also see the result of all this without downloading the release.


    Why are not many things automated, such as a bibliography?

    For one reason or another, I didn’t dig deeper into it, perhaps those who have hundreds of sources of used literature will be hurt.


    Does the pattern GOST / DSTU?

    I was guided solely by the requirements of the controller, so not really.


    Translation of the article into English on Medium .


    Also popular now: