Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to include some PDF I saved in Inkscape and change the width and the height at the same time. Is this possible? I tried \svgheight and it did not take both values at the same time.

This is what I do

\begin{figure}
  \begin{center}
    \def\svgwidth{0.75\columnwidth} 
    \input{illustration.pdf_tex}
  \end{center}
  \caption{Example}
  \label{figillustration}
\end{figure}

In the past I had the option of doing this:

\begin{figure}
  \begin{center}
    \includegraphics[height=3.0in,width=3.8in,angle=0]{img_1.jpg}
    \caption{Example}
  \end{center}
\label{figgordon}
\end{figure}

(setting both the width and the height).

How do I do this now?

share|improve this question
    
Is illustration.pdf_tex a PDF file or a TeX source document? If it's a PDF, you should be able to include it using \includegraphics if you correct the suffix to .pdf. –  Jake Mar 1 '12 at 5:22
    
@Jake, the question refers to the pdf + TeX output from inkscape which does give a pdf_tex extension. –  Eshwar May 1 '12 at 21:41
add comment

2 Answers

It seems like you checked the "PDF+LaTeX: Omit text in PDF, and create LaTeX file" option when exporting the file:

enter image description here

This creates two files: .pdf and .pdf_tex. The former is the non-text image in PDF form, while the latter contains the necessary image inclusion and text-related content, which should be rendered from within LaTeX. The problem is that the image inclusion looks like this:

\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.27558594pt}
  \else
    \setlength{\unitlength}{\svgwidth}
  \fi
  \global\let\svgwidth\undefined
  \makeatother
  \begin{picture}(1,1.4142857)%
    \put(0,0){\includegraphics[width=\unitlength]{tex.pdf}}%
     % <other text stuff>
    \end{picture}%
\endgroup

Apart from some other nasty stuff, it defines \svgwidth if you don't define it. However, as is evident from the \includegraphics code, it only provides a width adjustment. Hence your problem with \svgheight not working.

Here are my suggestions:

  • If you're interested in scaling the image proportionally, only set \svgwidth;
  • If you don't have any text that requires conversion from Inkscape to LaTeX, export to .pdf without the "PDF+LaTeX: Omit text in PDF, and create LaTeX file" option checked. That way you can include the image as usual via \includegraphics[width=<wd>,height=<ht>]{<file>}; or
  • Include the image using

    \begin{figure}
      \centering
      \newsavebox{\myimage}% Box that will store image
      \begin{lrbox}{\myimage}
        \input{tex.pdf_tex}% Actual image and text
      \end{lrbox}
      \resizebox{3.8in}{3in}{\usebox{\myimage}}% Resize box
      % <caption> <label>
    \end{figure}
    
share|improve this answer
add comment

Will this be useful?

\begin{figure}
  \centering
  \def\svgwidth{\columnwidth}
    \resizebox{0.75\textwidth}{!}{\input{illustration.pdf_tex}}
  \caption{Example}
  \label{fig:illustration}
\end{figure}

Using \begin{center} gives extra vertical space. It is advisable to use \centering

May be this article is useful.

Edit-1:

From Inkscape you can export your diagram as tikz code. you have to install inkscape2tikz extension from here. Once installed, figures can be exported as tikz code (Extensions->Export->Export to TikZ path). Say you save the exported file as figure.tex. Now, in your latex main file you have to include this:

\begin{figure}[!htb]
\centering
\resizebox{0.75\textwidth}{!}{\input{figure.tex}}
\caption{Caption of the figure} \label{fig:myfigure}
\end{figure} 

You have to put figure.tex and your main latex file in the same folder or full path to figure.tex has to be specified like \input{C:/figure-files/figure.tex}. I always go by this method.

There is another way where you can export the figure as .pdf file (not as .pdf_tex) (file->save as->figure.pdf). Then you can include it like:

\begin{figure}[!h]
\centering
\includegraphics[width=0.75\textwidth,height=0.5\textheight]{figure.pdf}
\caption{Caption of the figure}
\label{fig:myfigure}
\end{figure}

But here if you change the font of the document, fonts in figure won't match properly. Also it is better to keep the aspect ratio. This is done by mentioning only width or height of the figure.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.