Skip to content

Commit

Permalink
Docker fixup (#9)
Browse files Browse the repository at this point in the history
* Added support for automatic svg to pdf conversion

* Added automatic main file detection to Makefile

* Fixed docker call that messed up paths in e.g. synctex

* Fixed conditional setting of DISS variable

* Changed load order of the hyperref and glossaries package

* Removed debug line in Makefile

* Removed hardcoded diss volume from Dockerfile

* Changed makeglossaries sub to the one in the CTAN rc-examples
  • Loading branch information
mvonbun authored and andre-richter committed Jan 15, 2019
1 parent 83cd9d3 commit b60a023
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 35 deletions.
4 changes: 0 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,3 @@ RUN set -x; \
apt-get autoremove -q -y; \
apt-get clean -q -y; \
rm -rf /var/lib/apt/lists/*

VOLUME ["/diss"]

WORKDIR /diss
17 changes: 16 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
# set your dissertation main file here
DISS = dissertation.tex

# automatic main file detection
NUMMAINS = $(shell grep --files-with-matches --exclude="_*_.tex" \
'^\\documentclass' *.tex | wc -l)
ifeq ($(NUMMAINS), 1)
override DISS = $(shell grep --files-with-matches --exclude="_*_.tex" \
'^\\documentclass' *.tex)
else
$(warning *** Could not determine main LaTeX file)
$(warning Found $(NUMMAINS) potential main files)
$(warning Trying fallback to $(DISS))
$(warning You might want to either delete all files containing '\documentclass')
$(warning or specify your main file in the Makefile explicitly)
endif

TEX = latexmk
TEXFLAGS = -recorder -pdf
TEXCLEAN = -bibtex -c

DOCKER = docker run -it --rm -v $(shell pwd):/diss \
DOCKER = docker run -it --rm -v $$(pwd):$$(pwd) -w $$(pwd) \
andrerichter/tum-dissertation-latex

.PHONY: docker clean crop pdf-local clean-local crop-local placeholder placeholder-local
Expand Down
Binary file modified dissertation.pdf
Binary file not shown.
74 changes: 51 additions & 23 deletions dissertation.tex
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,6 @@
% (2) Inconsistent anchors in hyperref.
\usepackage{scrhack}

% glossary functionality
\usepackage[
toc,
acronym,
style = long
]{glossaries}
\makeglossaries

% figure inclusion
\usepackage[
Expand All @@ -162,21 +155,6 @@
% enumeration
\usepackage{enumerate}

% hyperlinks
\usepackage{url}
\usepackage[
hidelinks,
bookmarksnumbered
]{hyperref}

% If hyperref is used, references to tables and figures link to their captions
% and not the actual tables or figures. This is especially unwanted for figures,
% because their captions are below the figure so that clicking on a link just
% shows the captions and the figure is invisible.
%
% Using the caption package fixes this behaviour.
\usepackage{caption}

% Source code with highlighting
\usepackage{listings}
\lstset{
Expand Down Expand Up @@ -219,12 +197,41 @@
% dummy text
\usepackage{lipsum}

% hyperlinks
% according to its documentation, hyperref should be loaded last
% a list of packages that should be loaded after hyperref can be found at
% https://tex.stackexchange.com/questions/1863/which-packages-should-be-loaded-after-hyperref-instead-of-before
\usepackage{url}
\usepackage[
hidelinks,
bookmarksnumbered
]{hyperref}

% If hyperref is used, references to tables and figures link to their captions
% and not the actual tables or figures. This is especially unwanted for figures,
% because their captions are below the figure so that clicking on a link just
% shows the captions and the figure is invisible.
%
% Using the caption package fixes this behaviour.
\usepackage{caption}

% glossary functionality
% loading glossaries after hyperref adds hyperlings to acronyms and glossary
% entries
\usepackage[
toc,
acronym,
style = long
]{glossaries}
\makeglossaries

%-------------------------------------------------------------------------------
% Include custom packages here
%-------------------------------------------------------------------------------

% \usepackage{}


%-------------------------------------------------------------------------------
% TUM CI colors for PGF
%-------------------------------------------------------------------------------
Expand Down Expand Up @@ -344,7 +351,7 @@ \chapter{State of the Art}
\label{chap:sota}

Example citations~\cite{barham2003xen, LIS}.

Example acronym usage \gls{cpu}.


\chapter{Content}
Expand Down Expand Up @@ -508,6 +515,22 @@ \subsection{Example Barchart}



\subsection{Example SVG Graphics Input}

\lipsum[1]

\begin{figure}[thb]
\centering
\includegraphics{shapes}

\caption{Example Shapes from an SVG.}
\label{fig:example_svg}
\end{figure}

\lipsum[42]



\subsection{Example Source Code}

\lipsum[1]
Expand Down Expand Up @@ -598,3 +621,8 @@ \chapter{Additional Stuff}
\lipsum[1-4]

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
26 changes: 19 additions & 7 deletions latexmkrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# sources / example rcfiles
# https://www.ctan.org/tex-archive/support/latexmk/example_rcfiles

# compiler options
$pdflatex = 'TEXINPUTS="./inc//:" pdflatex -interaction=batchmode -shell-escape -synctex=1 %O %S';
$pdf_mode = 1;
Expand All @@ -6,14 +9,23 @@ $bibtex_use = 1;
# glossary and acronyms using the 'glossaries' package
add_cus_dep('glo', 'gls', 0, 'run_makeglossaries');
add_cus_dep('acn', 'acr', 0, 'run_makeglossaries');

sub run_makeglossaries {
if ( $silent ) {
system "makeglossaries -q '$_[0]'";
}
else {
system "makeglossaries '$_[0]'";
};
my ($base_name, $path) = fileparse( $_[0] );
pushd $path;
if ( $silent ) {
my $return = system "makeglossaries -q $base_name";
} else {
my $return = system "makeglossaries $base_name";
};
popd;
return $return;
}

# svg figure conversion using inkscape
add_cus_dep('svg', 'pdf', 0, 'run_svgtopdf');

sub run_svgtopdf {
system("inkscape --without-gui --export-area-drawing --export-pdf=$_[0].pdf $_[0].svg")
}

# clean up support for glossary and acronym files
Expand Down
80 changes: 80 additions & 0 deletions shapes.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b60a023

Please sign in to comment.