# Xfig: export a grid and a dot inside a coloured rectangle

I have this 1D_BZ_modif.fig file:

#FIG 3.2  Produced by xfig version 3.2.5c
Landscape
Center
Metric
A4
100.00
Single
-2
1200 2
1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 0 6975 142 142 0 6975 142 6975
1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 1414 6975 142 142 1414 6975 1556 6975
1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 2121 6975 142 142 2121 6975 2263 6975
1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 2827 6975 142 142 2827 6975 2969 6975
1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 3534 6975 142 142 3534 6975 3676 6975
1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 4241 6975 142 142 4241 6975 4383 6975
1 3 0 1 0 0 100 -1 20 0.000 1 0.0000 675 6975 142 142 675 6975 817 6975
2 2 0 1 0 30 50 -1 20 0.000 0 0 -1 0 0 5
360 6615 1067 6615 1067 7322 360 7322 360 6615
3 2 1 1 0 7 50 -1 -1 4.000 0 1 1 2
13 0 1.00 60.00 120.00
13 0 1.00 60.00 120.00
360 7515 1080 7515
0.000 0.000
3 2 0 5 4 7 50 -1 -1 0.000 0 1 0 2
1 1 6.00 60.00 120.00
2827 6975 3534 6975
0.000 0.000
3 2 0 2 0 7 50 -1 -1 0.000 0 0 0 2
-1080 6975 13950 6975
0.000 0.000
4 0 0 50 -1 0 20 0.0000 6 285 450 495 7875 $b$\001
4 0 0 50 -1 0 20 0.0000 6 315 4005 2925 7425 $\\textcolor{red}{\\mathbf{b}}$\001


in which there is:

1) Latex fonts

2) A grid

3) A chain of black dots, one of them is in a pink shaded rectangle:

In order to compile all this information in a single eps output, according to the official documentation, the Combined PS/Latex option has to be used in the Export menu:

1) Open the xfig file: xfig 1D_BZ_modif.fig

2) File / Export / Combined PS/LaTeX (both parts) / Export all layers / Export. This generates a 1D_BZ_modif.pstex_t file.

3) Create a file called 1D_BZ_modif.tex:

\documentclass{article}

\usepackage{epsfig}
\usepackage[dvipsnames]{xcolor} %(note: you might not might not need to do this)
\setlength{\textwidth}{100cm}
\setlength{\textheight}{100cm}
\begin{document}
\pagestyle{empty}
\input{1D_BZ_modif.pstex_t}
\end{document}


4) Now make:

latex 1D_BZ_modif.tex
dvips -E 1D_BZ_modif.dvi  -o 1D_BZ_modif.eps


This generates the following 1D_BZ_modif.eps file:

in which:

1) The grid does not appear

2) The black dot under the shaded pink rectangle also does not appear.

How could I make both that grid and black dot to appear in a final eps ?

• It's probably faster to re-draw it with tikz.... I am an unconditional of xfig, but it's not the most up-to-date sw around here.... May 21 '17 at 22:42

1) A grid is not stored in a fig-file, but must be given when exporting the figure. In the export dialog, File / Export / Combined PS/LaTeX, the Grid/Major field serves this purpose.

2) Since the black bullet is located at a greater depth than the pink rectangle, I understand that the OP asks the bullet to be drawn as if the pink rectangle were partially transparent. There are two possibilities:

A) Fake transparency, by painting the black dot as a circle with line width zero, filled with the same pink color as the rectangle, but shaded towards black (and located at a lesser depth than the pink rectangle). For instance, replace the first 9 numbers of the 7th line below 1200 2, i.e., 1 3 0 1 0 0 100 -1 20 by 1 3 0 0 0 30 40 -1 16.

Export to Combined PS/LaTeX using directly fig2dev, which is the frontend program that is called by xfig when exporting graphics. Here, a grid of 1 cm is demanded,

fig2dev -L pstex -G10mm 1D_BZ_modif.fig A.pstex
fig2dev -L pstex_t -p A.pstex 1D_BZ_modif.fig A.pstex_t


replace 1D_BZ_modif.pstex_t in the file 1D_BZ_modif.tex by A.pstex_t and produce the eps,

latex 1D_BZ_modif.tex
dvips -E 1D_BZ_modif.dvi -o 1D_BZ_modif.eps


B) For a better transparency effect, Xfig version >= 3.2.6 can export to tikz. The drawing specification of the rectangle in the tikz file would have to be manually edited by adding, e.g., opacity=0.5,

fig2dev -L tikz -G10mm -P 1D_BZ_modif.fig B.tex
edit B.tex
pdftex B.tex


The -P option creates a stand-alone tex file, instead of a tikz-file to be \input into a tex file, after \usepackage{tikz}\usetikzlibrary{arrows.meta}. The above creates B.pdf, which must be converted to eps. latex B.tex; dvips B.dvi produces an image that lacks the transparency effect.