How to obtain this graph in a PNG/GIF/JPG graph with transparent background?

%\usepackage[x11names,table]{xcolor} % colores por nombres y tablas. dddd%


\usepackage{hyperref} %Dudo si este paquete puede dar error al compilar con LATEX (no PDFLATEX)
\hypersetup{colorlinks=true, urlcolor=blue}

\headheight=15pt  %/ MARGENES y otros


%--------   Paquetes para uso con PSTricks  -----------------------------------------------%
% -------- Paquetes de pst-all \usepackage{pst-all}   paquete pstricks para las figuras en postcript
% ---- Fin Paquetes de pst-all
\usepackage{pst-fr3d}               % paquete pstricks para las figuras en postcript
\usepackage{pst-infixplot,pst-math} % paquete pstricks para las figuras en postcript
%%%%%   Paquetes para definir los "ladillos" de la parte superior de las páginas, los capítulos, las secciones y más cosas.
%%%%% La explicación de cómo se hace todo esto viene en las instrucciones que están incluidas en la instalacion.
%%%% Paquete para hacer los gráficos.   % OJO.- En alguna compilación me daba incompatibilidad de esta opción dvips con la clase article %
\usepackage[dvips]{graphicx}  % OJO.- HE QUITADO [dvips] antes de {graphicx} porque me daba error , y me pedía poner [dvips] en la clase principal, pero aparecía atenuado en article, como si no aceptase esta opción. Cargar despues de paquetes PSTricks
%--------   Fin Paquetes para uso con PSTricks  -------------------------------------------%

\usepackage{graphicx}    % paquete para insertar gráficos
\usepackage{epstopdf}    % para que funcioneen los eps con pdflatex
\usepackage{multicol}    % para incluir columnas multiples

\usepackage{marginnote}  % para crear notas al margen

\usepackage{mathpazo}    % para usar la fuente MathPAzo que me gusta más, yse lee bien.

\usepackage{anyfontsize} %

\usepackage{fancyhdr}   % Paquete para cabeceras y pies en cada página.
\pagestyle{fancy}       % seleccionamos un estilo

\renewcommand{\labelenumi}{\arabic{enumi}.- }   % personalizado a mi gusto los itemize.

\graphicspath{{G:/}{G:/Rafa/TEX Arquivos/}}

\settimeformat{ampmtime} % para incrustar fecha y hora en los documentos.

\spanishdecimal{.}       % Para usar el punto decimal, y no confundirlo con las comas.

% ///////////////////////////////////////////////////////////////////////////// %
%\cfoot{\includegraphics[width=11cm]{heado2}} % imagen centro del pie
\lhead{M.I.} % texto izquierda de la cabecera
%\chead{\today \;-\;  \currenttime } % texto centro de la cabecera
\rhead{Right Header} % número de página a la derecha
% - - -  - - - - - - - - - - -  - - - - - - - - - - -  - - - - - - - - %
\lfoot{{\gray{\footnotesize Compilado: \today \;-\;  \currenttime}}} % texto izquierda del pie
\rfoot{Página \thepage}
% texto derecha del pie
\cfoot{} % texto central del pie
\renewcommand{\headrulewidth}{0.4pt} % grosor de la línea de la cabecera
%\renewcommand{\footrulewidth}{0.1pt} % grosor de la línea del pie
% ///////////////////////////////////////////////////////////////////////////// %
%\title{Foro }
%\author{Rafa S.F.}
% //////////////////////////////////////////////// %


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   Figura 2.1

\ncline{->}{A}{B}\naput{\small $43$}
\ncarc[arcangleB=300]{->}{C}{B}\naput{\small $12$}
\ncarc{->}{C}{A}\naput{\small $23$}


  • By design, jpeg doesn't support transparency. – AlexG Jun 6 '13 at 10:43
  • @AlexG OK, you´re right, but PNG and GIF, yes. I know that GIF is a commercial format, so i prefer PNG. – Mika Ike Jun 6 '13 at 10:51
  • Why should it be transparent? Without using the environment pspicture you can draw over any object. – user2478 Jun 6 '13 at 14:51
  • @MikaIke: The patents on GIF are long expired; GIF is free. – Reinstate Monica - M. Schröder Jun 6 '13 at 14:56
  • @Herbert: I guess he wants to use it in a web page, perhaps with a wall paper behind. – AlexG Jun 6 '13 at 15:00

Using ImageMagick:

convert -density 300x300 simplenetwork02_stack.pdf -transparent white simplenetwork02_stack.png

To have just the PSTricks graphic as output, add


to the preamble. You may want to adjust the pspicture size to get a tightly boxed graphic:


enter image description here

  • Perfect!! I like your solution. Where i shoul type -convert density..... I usually click the PDFLATEX/xelatex icon, and obtain de PDF. img854.imageshack.us/img854/4679/snap2163.png – Mika Ike Jun 6 '13 at 19:31
  • 1
    @MikaIke: ImageMagick is a separate piece of software (independend from TeX), consisting of a number of commandline tools. You can download it from imagemagick.org. convert is run on the ready PDF file that was output by xelatex or latex->dvips->ps2pdf. – AlexG Jun 6 '13 at 19:53
  • \AlexG ok, i´m trying. – Mika Ike Jun 7 '13 at 5:51
  • Thank you, I downloaded imagemagick, but I don´t have a visual compiler. I like your solution, and I don´t know to abuse but... ¿Do you know about any other software to do this? I´m trying to install imagemagick,.. (windows).. but seems dificult. – Mika Ike Jun 7 '13 at 19:23
  • As I see that you control the situation :-) ... Any off-topic... I compile with Xelatex to can obtain the PSTricks picture, but it seems a little slow. What is the best option in your opinion? – Mika Ike Jun 8 '13 at 7:08

By default the canvas provided by pspicture is transparent. If you fill it with other colors such as psframe[fillstyle=solid,fillcolor=white]... then the canvas is no longer transparent.

\documentclass[pstricks,border=12pt]{standalone}% set border=0pt if you don't want to have borders.

Compile the code above to get a PDF output. And then use ImageMagick to convert it to PNG with transparency as follows.

convert -density 100 -alpha on filename.pdf filename.png

The output is

enter image description here

The quote markdown is used here to show the transparency effect clearly. The background looks yellowish that proves that it is really transparent!


-alpha has 3 mutual-exclusive options: on (enabling transparency), off (disabling transparency with bad output), and remove (removing transparency with good output).


The -transparent option explained and suggested by AlexG does not produce a good output as follows.

The following is the input. The red region will be converted to be transparent.

enter image description here

After conversion with convert -density 300 -transparent red in.pdf out.png, the output is as follows.

enter image description here

There are still red pixels on the boundaries of the red region. Are you satisfied with it? I don't.

  • I like your response. I downloaded ImageMagick, but It seems any ocmplicated. I have no Visual Studio to compile... and I haven´t benn capable to execute de "convert ...." command. Could you help me? – Mika Ike Jun 8 '13 at 7:10
  • 1
    @MikaIke: You should download the binary rather than the source code. I will give you the correct link to download the binary. Please wait in a couple of miliseconds. – kiss my armpit Jun 8 '13 at 7:14
  • 1
    @MikaIke: It is the link to download the binary for Windows: imagemagick.org/script/binary-releases.php#windows – kiss my armpit Jun 8 '13 at 7:16
  • Yes... i prefer a clean boundarie. Thank you very much :-)) I´m impresed. Do you recomend me any web with fantastic scientifics graphs/wallpapers? – Mika Ike Jun 8 '13 at 9:08
  • jajaja :-) please,... only 1 milisecond jajaja :-)))) – Mika Ike Jun 8 '13 at 9:09

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.