As my time at ETH will end, I started to move my blog entries from here to https://daester.com/blog.
Stay tuned, and thanks
Best
Simon
some thoughts and guides
As my time at ETH will end, I started to move my blog entries from here to https://daester.com/blog.
Stay tuned, and thanks
Best
Simon
I’m a fan of automatic builds. A lot of my gitlab/github projects are configured to do continuous integration (CI), which checks for errors in the projects.
This can also be used to automatically build your latex projects, in order to have a PDF for every build. Nice, isn’t it.
But let us not reach to the heaven until we did some dirty work by ourselfs. Builds must work on your computer first, then in the cloud.
To build local PDF, I use latexmk. It recognizes easily when a latex file has been modified and the PDF not. Let’s assume you have a paper called main.tex which uses a BibTeX reference file (called reference.bib, but that doesn’t matter for now). For the build, you usually must do
pdflatex main.tex
bibtex main.aux
pdflatex main.tex
(pdflatex main.tex)
There you go with builds.
latexmk does that for you. The build command is simple as
latexmk -pdf main.tex
Now, I have some SVG which need conversion to PDF before the build. The tool for that is cairosvg, a python program. You can get it on their webpage.
Now, it would be cumbersome to convert every SVG file even tough it has not changed. For that, we use the magic of the Makefile 🙂
When executing make it checks whether the SVG files have changed and only builds files which are newer than their corresponding PDF. Nice, right? To do that, i have a Makefile like this
# My Makefile
SVGS := $(wildcard chapter_*/images/*.svg)
PDFIMGS := $(patsubst %.svg, %.pdf, $(SVGS))
default: all
all: svg2pdf
svg2pdf: $(PDFIMGS)
%.pdf: %.svg
cairosvg --format pdf --output $@ $<
This is a typical Makefile. When executing make (or make all or make svg2pdf), it converts the only modified SVGs. Who this works, I have to lead you to other sources.
OK, so I can use latexmk to create my PDFs out of the tex files. And the Makefile to convert SVGs. Why not bring everything together, right?
There we go
SVGS := $(wildcard chapter_*/images/*.svg)
PDFIMGS := $(patsubst %.svg, %.pdf, $(SVGS))
default: all
all: svg2pdf mk
svg2pdf: $(PDFIMGS)
%.pdf: %.svg
cairosvg --format pdf --output $@ $<
mk:
latexmk
clean:
latexmk -c
I can only create the PDFs when executing make mk or only convert SVG when executing make svg2pdf. And when I want to clean the files from the latex compilation like aux and log files, I can use the command latexmk -c or with our Makefile make clean
We performe a local build for our latex project with
I use a simple gitlab configuration for my build in the cloud, which basically does the same thing as on the local machine. As there is no machine I set up myself in the cloud, I use a docker build. The file for the gitlab configuration is called .gitlab-ci.yml.
compile:
stage: build
image: daesters/latex
script:
- latexmk -c
- ./convertsvg2pdf.sh
- latexmk -pdf
#- latexmk
artifacts:
paths:
- ./dissertation.pdf
Cheers
When I try to open synaptic or gparted in Ubuntu 17.10, I run into problems. The error looks like this
No protocol specified
Unable to init server: Verbindung ist gescheitert: Verbindungsaufbau abgelehnt(synaptic:8832): Gtk-WARNING **: cannot open display: :0
To solve the problem, simple use the following command
xhost +SI:localuser:root
It is possible to create URL links in linux (well, I only have tested in in nautilus) to open in in browser by clicking.
This goes rather easily, but needs the right contents (link only is not sufficient). One can open a text editor and create a .desktop file. (i named it ethz-link.destkop). Important is the URL parameter
Now step by step
[Desktop Entry]
Encoding=UTF-8
Name=ETH Homepage
Type=Link
URL=https://www.ethz.ch
Icon=text-html
Looking for a good electronic labbook. Have a look at Elog. We use it in our research group. It is highly customizable and can be automated as well. Give it a try.