Skip to content

Commit

Permalink
Adds support for including .svg vector graphics. Closes #4.
Browse files Browse the repository at this point in the history
 * adds support for a direct inclusion
 * adds support to typeset the text using latex (and not SVG)
  • Loading branch information
koppor committed Nov 8, 2012
1 parent a7c2e76 commit 344abb9
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@
*.html
*.css
*.lg
ausarbeitung.pdf
ausarbeitung.pdf
graphics/*.pdf_tex
graphics/*svg-converted-to.pdf
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ editor = gedit
MASTER_TEX = ausarbeitung.tex
LITERATURE = bibliography/bibliography.bib

latex = pdflatex
#latex = pdflatex -shell-escape
#MiKTeX:
latex = pdflatex --enable-write18
bibtex = bibtex

SRC = $(shell basename $(MASTER_TEX) .tex)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ LaTeX compilation
=================
The template is compiled using normal LaTeX commands.

If you want to include .svg graphics, inkscape has to be in your path.

Usual LaTeX run
---------------

Expand Down
17 changes: 17 additions & 0 deletions content/kapitel2.tex
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,23 @@ \section{Abbildungen}
\end{center}
\end{figure}

Das SVG in \autoref{fig:directSVG} ist direkt eingebunden, während der Text im SVG in \autoref{fig:latexSVG} mittels pdflatex gesetzt ist.

\begin{figure}
\centering
\includegraphics{svgexample.svg}
\caption{SVG direkt eingebunden}
\label{fig:directSVG}
\end{figure}

\begin{figure}
\centering
\def\svgwidth{.4\textwidth}
\includesvg{svgexample}
\caption{Text im SVG mittels \LaTeX{} gesetzt}
\label{fig:latexSVG}
\end{figure}

\section{Tabellen}
Tabelle~\ref{tab:Ergebnisse} zeigt Ergebnisse.
\begin{table}
Expand Down
71 changes: 71 additions & 0 deletions graphics/svgexample.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 45 additions & 1 deletion preambel/packages_and_options.tex
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,55 @@
%%%
% Grafikeinbindungen
\usepackage{graphicx}%Parameter "pdftex" unnoetig
\graphicspath{{graphics/}}
\graphicspath{{\getgraphicspath}}
\newcommand{\getgraphicspath}{graphics/}
%
%%%


%%%
% Enables inclusion of SVG graphics - 1:1 approach
% This is NOT the approach of http://www.ctan.org/tex-archive/info/svg-inkscape,
% which allows text in SVG to be typeset using LaTeX
% We just include the SVG as is
\usepackage{epstopdf}
\epstopdfDeclareGraphicsRule{.svg}{pdf}{.pdf}{%
inkscape -z -D --file=#1 --export-pdf=\OutputFile
}
%
%%%


%%%
% Enables inclusion of SVG graphics - text-rendered-with-LaTeX-approach
% This is the approach of http://www.ctan.org/tex-archive/info/svg-inkscape,
\newcommand{\executeiffilenewer}[3]{%
\IfFileExists{#2}
{
%\message{file #2 exists}
\ifnum\pdfstrcmp{\pdffilemoddate{#1}}%
{\pdffilemoddate{#2}}>0%
{\immediate\write18{#3}}
\else
{%\message{file up to date #2}
}
\fi%
}{
%\message{file #2 doesn't exist}
%\message{argument: #3}
%\immediate\write18{echo "test" > xoutput.txt}
\immediate\write18{#3}
}
}
\newcommand{\includesvg}[1]{%
\executeiffilenewer{#1.svg}{#1.pdf}%
{
inkscape -z -D --file=\getgraphicspath#1.svg %
--export-pdf=\getgraphicspath#1.pdf --export-latex}%
\input{\getgraphicspath#1.pdf_tex}%
}
%%%

%%%
% Tabellenerweiterungen
\usepackage{array} %increases tex's buffer size and enables ``>'' in tablespecs
Expand Down

0 comments on commit 344abb9

Please sign in to comment.