2

Would you know a method for including xfig figures (.xfig) in PDFLatex, similarly as EPSTOPDF?

my example xfig file (test.xfig) is:

#FIG 3.2  Produced by xfig version 3.2.6a
Landscape
Center
Metric
A4
100.00
Single
-2
1200 2
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
  810 810 3465 810 3465 2385 810 2385 810 810
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
  2430 1215 5265 1215 5265 3105 2430 3105 2430 1215
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
  1125 1530 4140 1530 4140 3600 1125 3600 1125 1530
4 0 0 50 -1 0 12 0.0000 4 135 2070 1440 3060 Hello Latex Under Linux\001

For EPS, it can be done under Linux with (an heavy GS (ghostscript) installed). Ideally would be a xfigtopdf to do same thing.

\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{epstopdf}
\begin{document}
{\bfseries Minimal Example To Import EPS In PDFLATEX}
\begin{center}
\includegraphics[width=1.0\textwidth]{hellolatex.eps}
\end{center}
\end{document}

I am surprised that there is nothing for XFIG since EPS and XFIG are the most common file formats, used by expert scientists (veterans).

  • Would you mind explaining what your question is a bit better? You present a code that allows you to include eps files in a document that you process with pdflatex, right? And what you want to have is some package that allows you to include xfig figures while again processing with pdflatex, correct? Are you aware of fig2tikz? – user121799 Nov 19 '17 at 3:25
  • the idea would be to do same as for XFIG. I want to have xfig figures automatically into pdflatex, without having to export all the time. EPSTOPDF packages does that for EPS directly. likely a minimal fig2tikz might be of interest if it works as epstopdf. – user98734 Nov 19 '17 at 10:00
2

You can do this easily with fig2dev (from the transfig package) and the epstopdf package.

\documentclass{article}

\usepackage{filecontents}
\begin{filecontents*}{\jobname.xfig}
#FIG 3.2  Produced by xfig version 3.2.6a
Landscape
Center
Metric
A4
100.00
Single
-2
1200 2
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
  810 810 3465 810 3465 2385 810 2385 810 810
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
  2430 1215 5265 1215 5265 3105 2430 3105 2430 1215
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
  1125 1530 4140 1530 4140 3600 1125 3600 1125 1530
4 0 0 50 -1 0 12 0.0000 4 135 2070 1440 3060 Hello Latex Under Linux\001
\end{filecontents*}

\usepackage{graphicx}
\usepackage{epstopdf}

% add new rule to convert xfig to pdf
\epstopdfDeclareGraphicsRule{.xfig}{pdf}{.pdf}{fig2dev -L pdf #1 \OutputFile}
% automatically search for xfig extension (optional)
\AppendGraphicsExtensions{.xfig}

\begin{document}
\includegraphics{\jobname.xfig}
\end{document}

enter image description here

  • the workaround "\epstopdfDeclareGraphicsRule{.xfig}{pdf}{.pdf}{fig2dev -L pdf #1 \OutputFile}" works but it is highly dangerous and it could be endangering/crashing the computer. Furthermore, eps and xfig shall be separated and shall work well together. – user98734 Nov 19 '17 at 20:01
  • How is it different to using epstopdf for an EPS file? And in not sure what you mean by the second sentence. – David Purton Nov 19 '17 at 20:18
  • epstopdf shall be left as it is. Likely we should find a package that handles the xfig/fig figures, so that users can still see that their latex document can handle eps, xfig, png, .... as normally. – user98734 Nov 19 '17 at 20:37
  • You can still handle EPS, PNG, etc. as normal. \epstopdfDeclareGraphicsRule adds a rule for XFIG. It doesn't replace the rule for EPS. Try it—you can still include an EPS in my above example. The epstopdf package allows you to add as many rules as you want for different file types. You could also adjust it to use xfigtopdf instead of fig2dev if you wanted. I don't have xfigtopdf so I used fig2dev which is in CTAN. This method is also no more dangerous than using epstopdf for EPS files. You still have to use the --shell-escape flag to call GhostScript as well. – David Purton Nov 19 '17 at 23:11
  • 1
    Read section 1.6 of the epstopdf package manual. It says: "The support that package epstopdf implements is not limited to EPS files. Other image conversions can be declared." – David Purton Nov 19 '17 at 23:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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