2

I wanted to import a .pdf_tex file and I am not able to let the graphic appear correctly. What do I have to change?

Link to the document: Schichtung.svg Schichtung.pdf Schichtung.pdf_tex

\documentclass[10.5pt,a4paper,oldfontcommands]{memoir}

\usepackage[polutonikogreek, latin, english, french, ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage[dvips]{graphicx}
\usepackage{times}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{latexsym}
\usepackage{stmaryrd}
\usepackage{enumerate}
\usepackage{nicefrac}
\usepackage[all]{xy}
\usepackage{tabularx}
\usepackage{pst-plot,pstricks}
\usepackage{varwidth}
\usepackage{thmtools}
\usepackage{enumitem}
\usepackage{geometry}
\usepackage{float}
\usepackage{siunitx}
\usepackage{natbib} 
\usepackage{graphicx,xcolor}
\usepackage{epstopdf}
\usepackage{pdfpages}


\usepackage{transparent}
\graphicspath{{img/}}

\usepackage{pgfplots}
\def\FunctionF(#1){(#1)^3- 3*(#1)}%

\floatstyle{boxed} 
\restylefloat{figure} 

\usepackage{filecontents}

\usepackage[breaklinks=true,colorlinks=true, linkcolor=black,urlcolor=black,citecolor=black, bookmarks=true,bookmarksopenlevel=2]{hyperref}

\usepackage{geometry}
\geometry{total={210mm,297mm},
left=20mm,right=20mm,
bindingoffset=10mm, top=25mm,bottom=25mm}


\OnehalfSpacing
%\linespread{1.3}


\chapterstyle{lyhne}


\setsecheadstyle{\Large\bfseries\sffamily\raggedright}
\setsubsecheadstyle{\large\bfseries\sffamily\raggedright}
\setsubsubsecheadstyle{\bfseries\sffamily\raggedright}

\pagestyle{plain}
\makepagestyle{plain}
\makeevenfoot{plain}{}{}{\thepage}
\makeoddfoot{plain}{}{}{\thepage}
\makeevenhead{plain}{Kantonsschule Wettingen}{}{Potz Blitz - Gewitter in Theorie und Praxis}
\makeoddhead{plain}{Kantonsschule Wettingen}{}{Potz Blitz - Gewitter in Theorie und Praxis}

\maxsecnumdepth{subsection} 
\maxtocdepth{subsection} 
\bibliographystyle{ksfh_nat}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document} 


\begin{figure}
\centering
\def\svgwidth[width=\textwidth,page=-]
\input{Schichtung.pdf_tex}
\caption{hah}
\end{figure}




\end{document}
6
  • 1
    There is a } missing after ` bottom=25mm`
    – user2478
    Commented Oct 7, 2016 at 18:48
  • sorry this happened during the simplification of the code. how about the warning?
    – paris
    Commented Oct 7, 2016 at 19:20
  • can you share the content of x.pdf_tex? Commented Oct 7, 2016 at 19:23
  • I put the link to the document in the question
    – paris
    Commented Oct 7, 2016 at 19:33
  • How about if you use \input{Bilder/Thermodynamik/x.pdf_tex} instead of \import{} and remove the \def\svgwidth{200pt} line.
    – Dai Bowen
    Commented Oct 7, 2016 at 19:43

2 Answers 2

1

I removed a line-break in your text box for the word Index, as these line-breaks result in \\ being inserted - something not allowed in all situations. The resulting File > Save As... > Save as type > Portable Document Format (*.pdf) > PDF + LaTeX looks like this:

%% Creator: Inkscape 0.91_64bit, www.inkscape.org
%% PDF/EPS/PS + LaTeX output extension by Johan Engelen, 2010
%% Accompanies image file 'drawing.pdf' (pdf, eps, ps)
%%
%% To include the image in your LaTeX document, write
%%   \input{<filename>.pdf_tex}
%%  instead of
%%   \includegraphics{<filename>.pdf}
%% To scale the image, write
%%   \def\svgwidth{<desired width>}
%%   \input{<filename>.pdf_tex}
%%  instead of
%%   \includegraphics[width=<desired width>]{<filename>.pdf}
%%
%% Images with a different path to the parent latex file can
%% be accessed with the `import' package (which may need to be
%% installed) using
%%   \usepackage{import}
%% in the preamble, and then including the image with
%%   \import{<path to file>}{<filename>.pdf_tex}
%% Alternatively, one can specify
%%   \graphicspath{{<path to file>/}}
%% 
%% For more information, please see info/svg-inkscape on CTAN:
%%   http://tug.ctan.org/tex-archive/info/svg-inkscape
%%
\begingroup%
  \makeatletter%
  \providecommand\color[2][]{%
    \errmessage{(Inkscape) Color is used for the text in Inkscape, but the package 'color.sty' is not loaded}%
    \renewcommand\color[2][]{}%
  }%
  \providecommand\transparent[1]{%
    \errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package 'transparent.sty' is not loaded}%
    \renewcommand\transparent[1]{}%
  }%
  \providecommand\rotatebox[2]{#2}%
  \ifx\svgwidth\undefined%
    \setlength{\unitlength}{595.27559055bp}%
    \ifx\svgscale\undefined%
      \relax%
    \else%
      \setlength{\unitlength}{\unitlength * \real{\svgscale}}%
    \fi%
  \else%
    \setlength{\unitlength}{\svgwidth}%
  \fi%
  \global\let\svgwidth\undefined%
  \global\let\svgscale\undefined%
  \makeatother%
  \begin{picture}(1,1.41428571)%
    \put(0,0){\includegraphics[width=\unitlength,page=1]{drawing.pdf}}%
    \put(0.10986629,1.14048909){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{Absolute Stabilität}}}%
    \put(0.07946149,1.06923666){\color[rgb]{0,0,0}\rotatebox{90}{\makebox(0,0)[lb]{\smash{Druck }}}}%
    \put(0.26349269,0.86178884){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{Temperatur }}}%
    \put(0,0){\includegraphics[width=\unitlength,page=2]{drawing.pdf}}%
    \put(0.39389412,1.13949763){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{Bedingtre Labilität}}}%
    \put(0.3634893,1.06824514){\color[rgb]{0,0,0}\rotatebox{90}{\makebox(0,0)[lb]{\smash{Druck }}}}%
    \put(0.54752051,0.86079738){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{Temperatur }}}%
    \put(0,0){\includegraphics[width=\unitlength,page=3]{drawing.pdf}}%
    \put(0.69512417,1.13908496){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{Absolute Labilität}}}%
    \put(0.66471934,1.05976906){\color[rgb]{0,0,0}\rotatebox{90}{\makebox(0,0)[lb]{\smash{Druck }}}}%
    \put(0.84875061,0.8603847){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{Temperatur }}}%
    \put(0.09777096,0.79185788){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{Index}}}%
    \put(0,0){\includegraphics[width=\unitlength,page=4]{drawing.pdf}}%
    \put(0.12220724,0.77376786){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{Schichtungsgradient  }}}%
    \put(0.12181624,0.75578196){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{Feuchtadiabatischer Gradient }}}%
    \put(0.12142525,0.73740503){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{Trockenadiabatischer Gradient }}}%
    \put(0,0){\includegraphics[width=\unitlength,page=5]{drawing.pdf}}%
  \end{picture}%
\endgroup%

Note the comments showing the usage: \input{...pdf_tex}, not \import{...pdf_tex}.

The following minimal example was able to import the image:

enter image description here

\documentclass{article}

\usepackage{graphicx,xcolor}

\begin{document} 

\begin{figure}
  \centering
  \def\svgwidth{\textwidth}\footnotesize
  \input{drawing.pdf_tex}
\end{figure}

\end{document}

graphicx was needed to include the exported .pdf file, while xcolor was added since your image included colours.

If you're not drawing the image/plots inside LaTeX, you're left up to the conversion protocols of the image editor - Inkscape in this case - which may be limiting. Alternatively, export the image as a PDF without the LaTeX code and just use

enter image description here

\documentclass{article}

\usepackage{graphicx}

\begin{document} 

\begin{figure}
  \centering
  \includegraphics[width=\textwidth]{drawing}
\end{figure}

\end{document}
1
  • Thank you for your help. But if I wanted to compile the code it still had an error message. So now I tried something else but the pic still doesn't appear. I adjusted the code again and put the link of my files in the question
    – paris
    Commented Oct 8, 2016 at 9:41
1

I see two problems with your code:

1) The syntax is wrong: instead of \def\svgwidth[width=\textwidth,page=-] it should be \def\svgwidth{\textwidth}

2) inside Schichtung.pdf_tex line 64, remove the two slashes after Index:


And make sure, Schichtung.pdf_tex is in the same directory as your tex file, the \graphicspath won't work for \input

enter image description here

Offtopic: I think if you use lines in your plots, you should also show lines of the respective colour in the legend and not boxes.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .