Graphics, Figures & TablesCorrect font to use in Xfig

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
xbc
Posts: 6
Joined: Mon Apr 30, 2012 12:47 am

Correct font to use in Xfig

Post by xbc »

Hello!

I am currently working on a set of figures for a book (though I am no where cool enough to say it's for my own book! lol). I was told that the figures need to be in the .eps file format, but found out recently you cannot embed LaTeX code for any text used in the figure (i.e. number/axis labeling). The source of this discovery is here, under "Type B":

http://epb.lbl.gov/xfig/frm_miscellaneous.html

So per their advice at this link, is to use a font in Xfig that matches or most closely matches the font used in LaTeX. Like my previous dilemma, I am not sure what the name of the default font is that is used for text and math symbols in LaTeX.

If anyone knows, that would be great. Thanks!

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

shadgrind
Posts: 140
Joined: Thu Jul 16, 2009 12:39 am

Correct font to use in Xfig

Post by shadgrind »

Instead of using the Type B scenario, use Type C: PostScript/LaTeX format. That will render text (including math symobols) with the LaTeX fonts in your document. Follow these steps:

1. Run this command to start xfig:

Code: Select all

xfig -specialtext -latexfonts -startlatexFont default
2. Create your xfig figure, or open an existing one. You can put LaTeX characters in your text labels, e.g. $x^2 + y^2 = z^2$.

3. Go to File --> Export, then in the Language option select "Combined PS/LaTeX (both parts)". Save your file with a .pstex extension, e.g. myfigure.pstex. This will create two files: myfigure.pstex and myfigure_t.pstex. The first is the EPS figure and the second is a LaTeX file that handles the text for the EPS figure.

4. In your LaTeX document you input the myfigure_t.pstex file where you want the figure to appear:

Code: Select all

\input{myfigure_t.pstex}
Doing all this with new xfig figures should work fine. The only possible snag might be with exporting existing xfig figures that were not created with the special xfig command-line parameters from step 1. So worst case you may have to redo those figures. But in the end you'll have LaTeX fonts in your figures.
System: TeX Live 2012, Fedora 18 x86_64, GNU Emacs 24.2
xbc
Posts: 6
Joined: Mon Apr 30, 2012 12:47 am

Correct font to use in Xfig

Post by xbc »

Thank you shadgrind for the response! Sorry it has taken me a bit to respond. I am having problems going with the Type C scenario. I feel like it might be because I am using Xfig through a cygwin/Xwin server on a Windows OS system. I might also be forgetting a package to declare in the preamble. The epsfig package is declared though, but I don't think that helps. Here is what happened when I tried the steps you gave me:

I created a triangle with the Pythagorean Theorem under it along with "This is triangle $ABC$", and exported it as triangle.pstex; after exporting I had the triangle.pstex file, but instead of the triangle_t.pstex file, I instead had a triangle.pstex_t.

In my LaTeX document, I put in as the code,

\input{triangle.pstex_t}

and am able to compile it (into DVI or through PS into PDF), except I get an undefined control sequence warning (for each line of text). As for the actual figure, the figure shows up, the text shows up the way it should be, except along with it there are the symbols "[rbg]0,0,0" at the beginning of each block of text.

I admit I am not familiar with operating systems outside of Windows, so I do very much appreciate the help. Also, I am using TeXnic Center as my compiler, so maybe the issue is also there. It was suggested to me that I try TeX Studio.

Thanks again!
User avatar
shadgrind
Posts: 140
Joined: Thu Jul 16, 2009 12:39 am

Correct font to use in Xfig

Post by shadgrind »

You may have to use the xcolor package. Try this basic LaTeX file (call it test.tex):

Code: Select all

\documentclass{article}
\usepackage{xcolor}
\usepackage{graphicx}
\begin{document}
\begin{center}
 \input{triangle.pstex_t}
\end{center}
\end{document}
That should work with a standard latex+dvips+ps2pdf compilation, via these commands in a terminal window:

Code: Select all

latex test.tex
dvips -Ppdf -G0 -z test.dvi
ps2pdf test.ps
System: TeX Live 2012, Fedora 18 x86_64, GNU Emacs 24.2
xbc
Posts: 6
Joined: Mon Apr 30, 2012 12:47 am

Re: Correct font to use in Xfig

Post by xbc »

Using the xcolor package makes it work beautifully! (The preamble already had the graphicx package.) Thank you very much shadgrind!
Post Reply