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.

When I resize my pdf figures and graphs I often find that the text in these figures become too small to read. Is there a way of ensuring that the font in figures match the body text?

share|improve this question
3  
It is possible with EPS files (see Replacing labels in EPS file by LaTeX - text not where it should be), but I don't know for PDFs. –  Martin Scharrer May 7 '11 at 18:26
2  
No it is impossible with .jpg .png etc. The only reason OCR software exist is that after an image is created everything is in sort of pixels. Best is to generate your figures with TikZ then you wouldn't have this problem. –  Yiannis Lazarides May 7 '11 at 19:51
7  
Where are your figures coming from? If they are plots generated by something like Python, R, MATLAB, GnuPlot, etc, we may be able to suggest ways of getting LaTeX-friendly output. –  Sharpie May 7 '11 at 20:51
1  
Sorry about the vague question. My images are not bitmaps they are vector graphics created in programs like Inkscape, Mathematica, and GnuPlot. They are saved as pdf files which remain as vector graphics. –  cue May 8 '11 at 10:27
1  
@cue: you could edit your question to include that information about the origin of your graphics –  Martin May 27 '11 at 1:37

3 Answers 3

up vote 3 down vote accepted

You can include SVG images generated with Inkscape and process all the text inside Latex. The procedure is described in: "How to include an SVG image in LATEX". The following file illustrates the procedure.

You can also make free standing Inkscape/Latex graphics. Look at my answer "Need recommendations for a drawing tool in LaTeX"

\documentclass{article}
\usepackage{color}
\usepackage{graphicx}

\newcommand{\executeiffilenewer}[3]{%
    \ifnum\pdfstrcmp{\pdffilemoddate{#1}}%
        {\pdffilemoddate{#2}}>0{\immediate\write18{#3}}
    \fi}

\newcommand{\includesvg}[1]{%
    \executeiffilenewer{#1.svg}{#1.pdf}%
        {inkscape -z -D --file=#1.svg --export-pdf=#1.pdf --export-latex}%
    \input{#1.pdf_tex}}

\begin{document}
\begin{figure}
    \centering
    %\def\svgwidth{\columnwidth}
    \includesvg{svgfig}
    \caption{My SVG Image}
\end{figure}
\end{document}

Compile the file with

pdflatex -shell-escape <filename>

Make sure the Inkscape is in your path

enter image description here

share|improve this answer
    
I'd just want to point out that SVG != Inkscape (I think Inkscape produces bloated SVG; I always "draw" in a text-editor :^}) –  morbusg May 27 '11 at 13:03

I've had a lot of success with the pgfplots package. It doesn't resize figures, but rather uses LaTeX and the pgf package to create the figures. It's been a while since I've used GnuPlot, but from what I can remember, the types of plots that pfgplots can create is very similar to what GnuPlot can create. For example, you can have it read in data from files, or you can specify functions to plot. There's even limited 3D plotting.

To me, the best part is that if you want to change the figure size, you simply add a command like "width=6cm", and the plot automatically resizes, but the fonts stay the same size. Also, if you have mathematical expressions in the labels, they will be typeset in the same font as your paper, giving a very nice, consistent look.

share|improve this answer

In general, this should be possible quite comfortably with IPE http://ipe7.sourceforge.net/, which is a very powerful editor for creating vector graphics containing LaTeX text.

I used to create my graphics in an "arbitrary" size and then happily scaled them with \includegraphics[width=\textwidth]{...}and as a result had different line widths and font sizes. For a more consistent layout of my Ph. D. thesis I decided to include all graphics at 100% size and scale them with IPE. So I've created a template for IPE which has the size of the \textwidthand \textheight of my LaTeX document. (If the image does not use the whole text size, the PDF cropbox can be used as in my example.)

Example (quick and dirty) 2 created with IPE

I took one of my graphics and scaled a copy of it - you see that the line widths and text sizes are identical, just the size of the graphics elements has changed.

As you can see by the greek "my" letters, the alignment of the text labels is important when scaling. The my's in the example are aligned on their baseline, so if you downscale the image, they approach the x axis. You could also set their vertical alignment to "top" which should avoid that behavior.

I'm not an expert for using IPE, so I'm not sure what is the best way to do it - you could ask a question in the mailing list http://old.nabble.com/Ipe---General-f1929.html. There are also options to make text labels scale with the graphics, but the standard option leaves them in their size.

Some advantages of IPE:

  • you can use the same LaTeX fonts and font size as in the document
  • you can even use user-defined commands by including them in the LaTeX preamble of the IPE document (I have defined lots of mathematical symbols which I often use with commands. I keep the definitions in a separate .tex file, so I can use them consistently with \input{} as well in the preamble of my LaTeX document(s) as in all my IPE graphics
  • you can "import" and modify PDF files created with other software like gnuplot, mathematica or inkscape with the pdftoipecommand !
  • you can use any (AFAIK) LaTeX code you want in the IPE documents
  • you can save the file directly as (editable!! with IPE) PDF or EPS which can be used with includegraphics in your LaTeX document
  • you could also save in a text format .ipe which lets you edit files by text manipulations (if you know what you do - I wouldn't), however for including the graphics you'd have to then "render" it to PDF or EPS via a terminal command to apply the changes
  • it has a GUI and very powerful snapping features (however I recommend to read or at least browse the manual http://ipe7.sourceforge.net/manual/manual.pdf as many of those powerful features are not "obvious", but easy to learn
  • there are also commands for the command line to convert graphics, etc.
  • it's available for Linux, Windows and MacOS X (however not officially supported for OS X)
  • it's actively developed and has a very responsive developer and user community

  • I tried to add the original PDF file of my example graphics which is editable with IPE, but I don't see a way to upload it directly here. I tried to add the XML source code, but seems to be too long for the answer and it not displayed completely.

I've finally uploaded the example PDF file here (sorry for advertisement, be sure to click on the correct download button!!): link to pdf file

share|improve this answer
    
sounds like a good program. Is there an installer for windows? I have been battling to get it running. –  Yiannis Lazarides May 27 '11 at 8:39
1  
@Yiannis: It's a great software! I'm using it on MacOS X. The homepage says: "The Windows binary version consists of two zip files. You need both the package ipe-7.0.14-win.zip and the package ipe-7.0.0-dependencies-win.zip. Unzip the first package somewhere on your computer, but choose a location whose path contains no non-ASCII characters. Then unzip the dependencies package into the top-level directory of the first package, that is, into the directory ipe-7.0.14.", so that should be possible. If it doesn't work, have a look at the mailing list archives old.nabble.com/Ipe-f1928.html –  Martin May 27 '11 at 8:49

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.