2

At the out set, I must say I have just started using Tikz. I draw a picture using Tikz. It generated pdf output which I converted to eps (required figure format for submission in a journal) using pdftops. When I include eps file in my main latex document, it became transparent although eps file is not transparent. Please suggest something to rectify it. Thanks a lot

Here is the source code for generating pdf from Tikz:

\documentclass[class=minimal,border=0pt]{standalone}
\usepackage{tikz,tikzorbital}
% Tikz
\usepackage{tikz}
\usetikzlibrary{intersections}
\usetikzlibrary{shapes,decorations,shadows}  
\usetikzlibrary{decorations.pathmorphing}  
\usetikzlibrary{decorations.shapes}  
\usetikzlibrary{fadings}  
\usetikzlibrary{patterns}  
\usetikzlibrary{calc} 
\usetikzlibrary{arrows}
% \usetikzlibrary{arrows.meta}
\usetikzlibrary{automata}
\usepackage{tikzorbital}

\pgfkeys{/tikz/.cd,
    execute style/.style = {#1},
    execute macro/.style = {execute style/.expand once=#1}
}
% % -----------------------------------------------------------------------------
% % some customization of orbital
% % -----------------------------------------------------------------------------
% 
% inner color for orbital filling

\colorlet{innerColor}{black!10}

% color for orbital drawing

\colorlet{drawColor}{black!80}

% more style for lobe orbital drawing

\newcommand{\setOrbitalDrawingNew}[1]{\def\orbitalDrawingNew{#1}}
\setOrbitalDrawingNew{thick}
% general style

\tikzstyle{base} = [draw = drawColor, thick, inner color = innerColor, 
        circle, opacity = 1, 
            execute macro = \orbitalDrawingNew]
% Tikz

\begin{document}
\begin{tikzpicture}[scale=1]
\foreach \myscale in {.9}
{
\foreach \y in {-1}
{\begin{pgfonlayer}{background}
 \draw [ultra thick] (-3.4cm,\y cm) -- (3.4cm,\y cm); 
    \node[left,thick] at (-3.8cm,\y cm) {$(a)$};
\end{pgfonlayer}
\foreach \x in {-3,-1,..., 4}
\shade[ball color=green] (\x cm,\y cm) circle (.21cm);

\foreach \x in {-2,0,...,3}
{
\orbital[pos = {(\x cm,\y cm)},color=red,scale=\myscale]{lobe};
        \begin{pgfonlayer}{background}
        \node at (\x cm,\y cm) [ellipse, minimum width = \myscale * .3cm, 
              minimum height = \myscale * .8cm, draw = drawColor, 
              inner color = innerColor, outer color = blue, 
              execute macro = \orbitalDrawingNew] 
            {};
        \end{pgfonlayer}
 \orbital[pos = {(\x cm,\y cm)},color=red,scale=\myscale,rotate=180]{lobe};
}}}
\end{tikzpicture}
\end{document}
  • Welcome to TeX.sx! Formatting tip: you can format blocks of code by adding 4 spaces in front of each line, or by selecting the block of text and clicking the {} button above the editor. – T. Verron Jul 2 '14 at 13:27
  • 1
    Why not using the pdf file directly? – percusse Jul 2 '14 at 13:33
  • Publisher accepts only eps file. – Ravphys Jul 2 '14 at 13:39
  • 3
    Did you actually ask the publisher? Because a lot of publishers haven't updated their requirements in years. Also, isn't that requirement for external graphics? TiKz isn't exactly external. – daleif Jul 2 '14 at 13:54
  • Have you tried compiling the figure using latex -> dvips instead of pdflatex (which I assume you are currently using)? – Charles Staats Jul 2 '14 at 14:05
1

You can add a (white) background fill to the figure. I used the approach suggested by Alain Matthes in this answer. For some reason, manual scaling of the background fill was needed. Otherwise the dimensions of the figure would grow. It also appears that the background fill doesn't quite cover the whole image area.

The images below are screen captures from a viewer application, with a checkerboard pattern indicating transparency. pdftops -eps was used for PDF to EPS conversion and convert (no user-specified parameters except -density) from ImageMagick was used for conversion to PNG format.

I find it interesting how the intermediate step of conversion to EPS affects the final bitmap output from ImageMagick.

Images with the code from the question

PDF -> EPS -> PNG

Code from the question, PDF to EPS to PNG

PDF -> PNG

Code from the question, PDF to PNG

Images with the code from this answer

PDF -> EPS -> PNG

Code from this answer, PDF to EPS to PNG

PDF -> PNG

Code from this answer, PDF to PNG

\documentclass[class=minimal,border=0pt]{standalone}
\usepackage{tikz,tikzorbital}
% Tikz
\usepackage{tikz}
\usetikzlibrary{intersections}
\usetikzlibrary{shapes,decorations,shadows}  
\usetikzlibrary{decorations.pathmorphing}  
\usetikzlibrary{decorations.shapes}  
\usetikzlibrary{fadings}  
\usetikzlibrary{patterns}  
\usetikzlibrary{calc} 
\usetikzlibrary{arrows}
% \usetikzlibrary{arrows.meta}
\usetikzlibrary{automata}
\usetikzlibrary{fit}
\usepackage{tikzorbital}

\pgfkeys{/tikz/.cd,
    execute style/.style = {#1},
    execute macro/.style = {execute style/.expand once=#1}
}
% % -----------------------------------------------------------------------------
% % some customization of orbital
% % -----------------------------------------------------------------------------
% 
% inner color for orbital filling

\colorlet{innerColor}{black!10}

% color for orbital drawing

\colorlet{drawColor}{black!80}

% more style for lobe orbital drawing

\newcommand{\setOrbitalDrawingNew}[1]{\def\orbitalDrawingNew{#1}}
\setOrbitalDrawingNew{thick}
% general style

\tikzstyle{base} = [draw = drawColor, thick, inner color = innerColor, 
        circle, opacity = 1, 
            execute macro = \orbitalDrawingNew]
\pgfdeclarelayer{bgcolor}
\pgfsetlayers{bgcolor,background,main,foreground}

% Tikz

\begin{document}
\begin{tikzpicture}[scale=1]
\begin{scope}[local bounding box=bb]
\foreach \myscale in {.9}
{
\foreach \y in {-1}
{\begin{pgfonlayer}{background}
 \draw [ultra thick] (-3.4cm,\y cm) -- (3.4cm,\y cm); 
    \node[left,thick] at (-3.8cm,\y cm) {$(a)$};
\end{pgfonlayer}
\foreach \x in {-3,-1,..., 4}
\shade[ball color=green] (\x cm,\y cm) circle (.21cm);

\foreach \x in {-2,0,...,3}
{
\orbital[pos = {(\x cm,\y cm)},color=red,scale=\myscale]{lobe};
        \begin{pgfonlayer}{background}
        \node at (\x cm,\y cm) [ellipse, minimum width = \myscale * .3cm, 
              minimum height = \myscale * .8cm, draw = drawColor, 
              inner color = innerColor, outer color = blue, 
              execute macro = \orbitalDrawingNew] 
            {};
        \end{pgfonlayer}
 \orbital[pos = {(\x cm,\y cm)},color=red,scale=\myscale,rotate=180]{lobe};
}}}
\end{scope}
\begin{pgfonlayer}{bgcolor}
  \node [xscale=0.971,yscale=0.901,fill=white,fit=(bb)] {};
\end{pgfonlayer}
\end{tikzpicture}
\end{document}

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.