Graphics, Figures & Tables.pdf/.pdf_t resize problem with font size

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
silentboom
Posts: 11
Joined: Thu Sep 03, 2009 11:02 am

.pdf/.pdf_t resize problem with font size

Post by silentboom »

Hello everybody.

I have created some combined .pdf/.pdf_t graphics and then included them into my document.
Now it is necessary to resize those figures.

I know that one can do this with \resizebox, which also works fine.

But how can I achive that unless I resize the figure, the font size remains the same, as in the document?

Thanks for your help!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm

Re: .pdf/.pdf_t resize problem with font size

Post by php1ic »

Have you marked/flagged all of the text so it isn't included in the .pdf? \resizebox should then take care of font size and placement.

I output pstex/pstex_t from xfig, but assume the method used is the same. The idea of the combined output is that one file contains the lines and drawings and the other is a latex file that includes the 'line and drawing' file then places the text on top.

To check, open the .pdf file of the figure. There should be no text.
silentboom
Posts: 11
Joined: Thu Sep 03, 2009 11:02 am

.pdf/.pdf_t resize problem with font size

Post by silentboom »

I have just checked the pdf-file, and there is no text included in it.
In the document itself I used the following code to include it:

Code: Select all

\begin{figure}[h]
\resizebox{\textwidth}{!}{\input{foo.pdf_t}
}
\end{figure}


The file foo.pdf_t looks like this (which is a simple example, with the text $P_10$ only):

Code: Select all

\begin{picture}(0,0)%
\includegraphics{foo.pdf}%
\end{picture}%
\setlength{\unitlength}{4144sp}%
%
\begingroup\makeatletter\ifx\SetFigFontNFSS\undefined%
\gdef\SetFigFontNFSS#1#2#3#4#5{%
  \reset@font\fontsize{#1}{#2pt}%
  \fontfamily{#3}\fontseries{#4}\fontshape{#5}%
  \selectfont}%
\fi\endgroup%
\begin{picture}(3413,2812)(2142,-4175)
\put(2521,-1546){\makebox(0,0)[lb]{\smash{{\SetFigFontNFSS{12}{14.4}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}$P_1$}%
}}}}
\end{picture}%
In xfig I have set the fonttype to latex default.
Maybee I have to set the fontsize to default size too, but I couldn't find an option in xfig to do that.
I guess the problem is that I surround the entire foo.pdf_t with the \resizebox.
Any hint to do it better?
(To be honest, I am not a LATEX-Pro.)
php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm

Re: .pdf/.pdf_t resize problem with font size

Post by php1ic »

I include my figures the same way and your pdf_t file has the same things as mine. I assume as you create two files that you have given the text the special flag?

What actually happens to the text when you use the \resizebox?
Do you compile with pdftex or latex?
silentboom
Posts: 11
Joined: Thu Sep 03, 2009 11:02 am

.pdf/.pdf_t resize problem with font size

Post by silentboom »

I compiled it with pdfLatex. Assuming that I enlarge the figure, the text will be enlarged too.
I did set the special flag for the text.

In the image I have displayed the results I get when scaling it to 0.3\textwidth or 0.7\textwidth.
tt.jpg
tt.jpg (13.03 KiB) Viewed 10990 times
Thanks for your help.
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Re: .pdf/.pdf_t resize problem with font size

Post by phi »

Don't scale these figures with \resizebox, but create them with the desired size in the first place instead.
silentboom
Posts: 11
Joined: Thu Sep 03, 2009 11:02 am

Re: .pdf/.pdf_t resize problem with font size

Post by silentboom »

I have considered this as well. But often one doesn't know what size they will have when creating the figures. And to be honest: I thought that this is an advantage of using .pdf/pdf_t figures.
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Re: .pdf/.pdf_t resize problem with font size

Post by phi »

The advantage is that you get no quality loss and smaller files when using vector graphics, but still they are treated like a unit by \resizebox and the fonts cannot be scaled independently, no matter what the actual graphics format is. You'd get similar results when applying \resizebox to simple LaTeX text.
Apart from the text scaling problem, the line widths will probably get scaled, too. So I see no alternative than creating all graphics with the final dimensions. In fact, most graphics packages should allow to specify a custom coordinate system that doesn't depend on the physical dimensions of the image.
ekenny
Posts: 1
Joined: Tue Sep 15, 2015 3:12 pm

Re: .pdf/.pdf_t resize problem with font size

Post by ekenny »

I've collected all objects together in xfig using COMPOUND object, then resized to less than 8cm width for 2 column papers and it worked perfectly for some images but doesn't work for others. I'm using evince to view the PDFs under Linux. It turns out that it seemed to cache some of the locations somehow and the images were not generated correctly. After some time the caching disappeared and the images are now the correct sizes. Now I get perfectly sized images. It also affects the appearance of the first page when using IEEEtrans document class. When you have all images corrected the first page viewing problem goes away.
Post Reply