0

I would like to add a logo into my Latex document. Since using \includesvg did not work for me (I am using ubuntu and I have installed incscape) I resorted to manually converting the svg file into a pdf file.

But when I wanted to include this file in my Title (see 01_titel.tex) it print a bunch of character-errors. Does anybody know how to fix this and include the logo as a vector-graphic ?

You can find the tex file and the pdf / svg I want to include here: Here

Error when compiling the file

The easiest way would be to somehow include the svg directly into the tex file.

Here is my Tex File:

%Dokumentklasse
\documentclass[a4paper,12pt]{scrreprt}
\usepackage[left= 2.5cm,right = 2cm, bottom = 4 cm]{geometry}
%\usepackage[onehalfspacing]{setspace}
% ============= Packages =============

% Dokumentinformationen
\usepackage[
    pdftitle={Titel der Abschlussarbeit},
    pdfsubject={},
    pdfauthor={Euer Name},
    pdfkeywords={}, 
    %Links nicht einrahmen
    hidelinks
]{hyperref}


% Standard Packages
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage{graphicx, subfig}
\graphicspath{{img/}}
\usepackage{fancyhdr}
\usepackage{lmodern}
\usepackage{color}

% zusätzliche Schriftzeichen der American Mathematical Society
\usepackage{amsfonts}
\usepackage{amsmath}


%nicht einrücken nach Absatz
%\setlength{\parindent}{0pt}


% ============= Kopf- und Fußzeile =============
\pagestyle{fancy}
%
\lhead{}
\chead{}
\rhead{\slshape \leftmark}
%%
\lfoot{}
\cfoot{\thepage}
\rfoot{}
%%
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}

% ============= Package Einstellungen & Sonstiges ============= 
%Besondere Trennungen
\hyphenation{De-zi-mal-tren-nung}


% ============= Dokumentbeginn =============

\begin{document}
%Seiten ohne Kopf- und Fußzeile sowie Seitenzahl
\pagestyle{empty}
\begin{figure}
\centering
\def\svgwidth{175pt}
\input{img/thws-logo.pdf}
\caption{logo}
\end{figure}

\end{document}
tomle
  • 13
  • 4

1 Answers1

2

There's a package svg on CTAN, which adds \includesvg{<filename no ext>}, which simply loads your file similarly to \includegraphics from graphicx and accepts optional arguments like width, scale etc.

The code below should render following image

enter image description here

EDIT. Note the block filecontents*. This is to create a file in a root folder and is added to make example self-content. The test-svg.svg file would just be an external file copied to a project folder by you.

The code

\begin{filecontents*}[overwrite]{test-svg.svg}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   width="60.103493mm"
   height="50.85656mm"
   viewBox="0 0 60.103493 50.85656"
   version="1.1"
   id="svg5"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:svg="http://www.w3.org/2000/svg">
  <sodipodi:namedview
     id="namedview7"
     pagecolor="#505050"
     bordercolor="#ffffff"
     borderopacity="1"
     inkscape:showpageshadow="0"
     inkscape:pageopacity="0"
     inkscape:pagecheckerboard="1"
     inkscape:deskcolor="#505050"
     inkscape:document-units="mm"
     showgrid="false" />
  <defs
     id="defs2" />
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1"
     transform="translate(-66.909471,-25.283422)">
    <rect
       style="fill:#ff0000;stroke:#000000;stroke-width:1.76389"
       id="rect111"
       width="35.796261"
       height="26.072519"
       x="67.79142"
       y="26.165365" />
    <ellipse
       style="fill:#00ffff;stroke:#000000;stroke-width:1.76389"
       id="path165"
       cx="107.6892"
       cy="57.111996"
       rx="18.44182"
       ry="18.146046" />
  </g>
</svg>
\end{filecontents*}
%%%
\documentclass{article}
\usepackage{svg}

\begin{document}
\begin{figure}[tbh]
    \centering
    \includesvg[scale=1.2]{test-svg}
    \caption{Included SVG file}\label{fig:testsvg}
\end{figure}
\end{document}
deralbert
  • 856
  • 2
  • 15
  • 33
Celdor
  • 2,437
  • 2
  • 23
  • 44
  • Thank you for your response. This example code doesn't work for me. See the error here: https://imgur.com/a/sOf0AY2 – tomle Apr 07 '23 at 14:51
  • OK, I tested the code on Overleaf and didn't realise the code was compiled with additional flag `--shell-escape`. The flag allows LaTeX to run external programs, in this case Inkscape, which converts the file from SVG to PDF during compilation. You would have to tell your editor to use the flag and code should work. Also, make sure Inkscape is also available in command line, e.g. type 'inkscape -V' in command line to test it. – Celdor Apr 08 '23 at 09:07
  • It still didn't work for me but thanks tho – tomle May 23 '23 at 11:03
  • Wonderful answer, but there is a mistake in the command `\in**lc**udesvg{}`. It must be **`\includesvg{}`**! I guess I can't read well enough. Only after several hours I noticed that the several letters were in the wrong order. That was the reason for `Undefined control sequence. l.56 \inlcudesvg` by me. – deralbert Aug 10 '23 at 11:36
  • Oh, `\in**lc**udegraphics` is also misspelled. It should be `\includegraphics`. – deralbert Aug 10 '23 at 11:40
  • Sorry about the typos. I always test the code before posting but typos in text are harder to spot. Anyway thanks for the corrections. Next time, check the log file to save your time. LaTeX is quite robust at pointing the misspelled names. It simply provides the exact line number with the incorrect macro at the end. For instance if the line 15 has a following typo in `\label`: `\caption{Included SVG file}\lclbel{fig:testsvg}`, the report would be: `l.15 \caption{Included SVG file}\lclbel`. Hope it helps next time. – Celdor Aug 10 '23 at 13:23
  • Also, when you search the log file, start from the top to correct the first error. Usually, other problems if there are any are consequence of the first one. GL – Celdor Aug 10 '23 at 13:27