Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have drawn the following figure, showing a Euro symbol:

% http://upload.wikimedia.org/wikipedia/commons/5/57/Euro_Construction.svg

\documentclass{article}

\usepackage{pstricks}
\usepackage{expl3}

\ExplSyntaxOn
  \cs_new_eq:NN \calc \fp_eval:n
\ExplSyntaxOff


\begin{document}

\psset{
  unit = 0.8,
  linejoin = 1
}

\begin{pspicture}(-7.5,-6)(4.26,6)
 \pscustom[
   fillstyle = solid,
   fillcolor = yellow!70
 ]{
  \psline(\calc{6*sin(2*acot(6/5*sec(2/9*pi)+tan(2/9*pi)))},
          \calc{6*cos(2*acot(6/5*sec(2/9*pi)+tan(2/9*pi)))})%
         (\calc{5*cos(2/9*pi)},\calc{5*sin(2/9*pi)})
  \psarc(0,0){5}{40}{\calc{90+round(acosd(3/10),9)}}
  \psline(\calc{-sqrt(91)/2},1.5)%
         (\calc{75/2*cos(2/9*pi)/(6+5*sin(2/9*pi))},1.5)%
         (\calc{65/2*cos(2/9*pi)/(6+5*sin(2/9*pi))},0.5)%
         (\calc{-3/2*sqrt(11)},0.5)
  \psarc(0,0){5}%
         {\calc{ 90+round(acosd(1/10),9)}}%
         {\calc{270-round(acosd(1/10),9)}}
  \psline(\calc{-3/2*sqrt(11)},-0.5)%
         (\calc{55/2*cos(2/9*pi)/(6+5*sin(2/9*pi))},-0.5)%
         (\calc{45/2*cos(2/9*pi)/(6+5*sin(2/9*pi))},-1.5)%
         (\calc{-sqrt(91)/2},-1.5)
  \psarc(0,0){5}{\calc{270-round(acosd(3/10),9)}}{320}
  \psline(\calc{ 5*cos(2/9*pi)},\calc{-5*sin(2/9*pi)})%
         (\calc{ 5*cos(2/9*pi)},\calc{-sqrt(36-25*cos(2/9*pi)^2)})
  \psarcn(0,0){6}%
         {\calc{270+round(atand(5*cos(2/9*pi)/sqrt(36-25*cos(2/9*pi)^2)),9)}}%
         {\calc{270-round(acosd(1/4),9)}}
  \psline(\calc{-6*cos(1/4)},-1.5)%
         (-7.5,-1.5)%
         (\calc{5*cos(2/9*pi)/(6+5*sin(2/9*pi))-15/2},-0.5)%
         (\calc{-6*cos(1/12)},-0.5)
  \psarcn(0,0){6}%
         {\calc{270-round(acosd(1/12),9)}}%
         {\calc{ 90+round(acosd(1/12),9)}}
  \psline(\calc{-6*cos(1/12)},0.5)%
         (-7.5,0.5)%
         (\calc{5*cos(2/9*pi)/(6+5*sin(2/9*pi))-15/2},1.5)%
         (\calc{-6*cos(1/4)},1.5)
  \psarcn(0,0){6}%
         {\calc{90+round(acosd(1/4),9)}}%
         {\calc{round(atand(sec(2/9*pi)/10*(36-25*sin(1/18*pi)+60*sin(2/9*pi))%
                            /(6+5*sin(2/9*pi))),9)}}%
 }
\end{pspicture}

\end{document}

output

Is there a way of drawing the same figure using PSTricks without all the hard-coded values?

(See the link for how to make a geometrical construction of the symbol.)

share|improve this question
    
Which hard-coded values are you referring to? The angles would be the same regardless of the size. The lengths are relative to xunit/yunit/unit, so that doesn't really leave much else other than including an existing symbol (from a font, say, eurosym) or including the image after converting it. –  Werner Jul 21 at 19:40
    
@Werner I'm thinking of using something like, say, pst-eucl to 'construct' the symbol. –  Svend Tveskæg Jul 21 at 20:12
    
Explain what you mean by "without hard-coded values", please. Are you interested in scaling the image and the hard-coded values make this difficult? Or you just want something that is cleaner? Even with pst-eucl I don't think you'll get much cleaner. I still think my answer is the easiest and uses PSTricks. –  Werner Jul 21 at 20:19
    
By 'hard-coded' I'm thinking of all the values inside the \calcs. If I can construct the symbol and only use the values on the image in the link, I would like that. –  Svend Tveskæg Jul 21 at 20:22
    
@Werner: Your last link titled my answer points to a wrong target, I think. –  Who is crazy first Jul 22 at 15:05

2 Answers 2

up vote 8 down vote accepted

The Euro symbol is hard coded (http://en.wikipedia.org/wiki/File:EuroConstLarge.png). However, you can simplify it. Straight connections between two points can be omitted \pscustom does it by default when building the path:

\documentclass{minimal}
\usepackage{pstricks}

\begin{document}
\pstVerb{ 
  /c40 {40 cos }bind def
  /s40 {40 sin }bind def
  /s65 {6 5 s40 mul add }bind def
}
\begin{pspicture}(-7.5,-7.5)(7.5,7.5)
\pscustom[fillstyle=solid,fillcolor=black!20]{%
  \psarc(0,0){5}{40}{! 180 0.3 ATAN1 sub }
  \psline(! 37.5 c40 mul s65 div 1.5)(! 32.5 c40 mul s65 div 0.5)
  \psarc(0,0){5}{!180 0.1 ATAN1 sub}{!180 0.1 ATAN1 add}
  \psline(! 27.5 c40 mul s65 div -0.5)(! 22.5 c40 mul s65 div -1.5)
  \psarc(0,0){5}{!180 0.3 ATAN1 add}{320}  
  \psarcn(0,0){6}{! 270 5 c40 mul 36 25 c40 dup mul mul sub sqrt div ATAN1 add } 
                 {! 270 0.25 Acos sub }
  \psline(-7.5,-1.5)(!5 c40 mul s65 div 7.5 sub -0.5)
  \psarcn(0,0){6}{!180 1 12 atan add}{!180 1 12 atan sub} 
  \psline(-7.5,0.5)(! 5 c40 mul s65 div 7.5 sub 1.5)
  \psarcn(0,0){6}{!180 1.5 6 atan sub}
          {! 1 c40 div 10 div 36 25 10 sin mul sub 60 s40 mul add mul s65 div ATAN1}
 \closepath
}
\end{pspicture}

\end{document}

enter image description here

share|improve this answer
    
Thanks! Just to be clear: What do you mean by "streight lines"? (All lines are streight.) –  Svend Tveskæg Jul 21 at 21:43
1  
Compare my \psline sequences and yours. You have four coordinates and I used only two –  Herbert Jul 22 at 6:24

A solution with MetaPost which needs only the radius. Run it with context <file>:

\starttext
\setupcolors[state=start]

\startuseMPgraphic{dummy}
boolean trace_euro ; trace_euro := false ;
vardef euro_symbol = image ( % begin_of_euro
 if unknown euro_radius   : euro_radius := 2cm; fi;
 if unknown euro_width    : euro_width := 3euro_radius/16; fi;
 if unknown euro_r_offset : euro_r_offset:= euro_width; fi;
 if unknown euro_l_offset : euro_l_offset := euro_radius/32 ; fi ;
 if unknown euro_l_shift  : euro_l_shift := euro_r_offset ; fi ;
 if unknown euro_v_delta  : euro_v_delta := euro_width/4 ; fi ;
save
  outer_circle, inner_circle, hor_bar,
  right_line, right_slant, top_slant, bot_slant,
  euro_circle, euro_topbar, euro_botbar ;
path
  outer_circle, inner_circle, hor_bar,
  right_line, right_slant, top_slant, bot_slant,
  euro_circle, euro_topbar, euro_botbar ;
outer_circle := fullcircle scaled euro_radius ;
inner_circle := fullcircle scaled (euro_radius-euro_width) ;
if trace_euro : 
  for i = outer_circle, inner_circle :
    draw i withpen pencircle scaled 1pt withcolor .5white ;
  endfor ; 
fi ;
right_line := (lrcorner outer_circle -- urcorner outer_circle) shifted (-euro_r_offset,0) ;
outer_circle := outer_circle cutbefore right_line ;
right_slant := point 0 of outer_circle -- origin shifted (0,ypart lrcorner outer_circle) ;
euro_circle := buildcycle(outer_circle, right_line, reverse inner_circle, reverse right_slant) ;
hor_bar := (-euro_radius,0) -- (euro_radius,0) ;
top_slant := right_slant shifted (-euro_radius+euro_r_offset-euro_l_offset,0) ;
bot_slant := top_slant shifted (0,-euro_l_shift) ;
if trace_euro : 
  for i = right_line, right_slant, top_slant, bot_slant :
    draw i withpen pencircle scaled 1pt withcolor .5white ;
  endfor ; 
fi ;
euro_topbar := buildcycle (top_slant, hor_bar shifted (0, euro_v_delta),
                right_slant, hor_bar shifted (0, euro_v_delta+euro_width/2)) ;
euro_botbar := buildcycle (bot_slant, hor_bar shifted (0,-euro_v_delta),
                right_slant, hor_bar shifted (0,-euro_v_delta-euro_width/2)) ;
for i = euro_circle, euro_topbar, euro_botbar :
  draw i withpen pencircle scaled 0 ;
endfor ;
for i = euro_circle, euro_topbar, euro_botbar :
  fill i withpen pencircle scaled 0 ;
endfor ;
if trace_euro : 
  drawpoints euro_circle withcolor red;
  drawpoints euro_topbar withcolor green ;
  drawpoints euro_botbar withcolor blue ;
fi ;
) enddef ; % end_of_euro
euro_radius := 4cm ; draw euro_symbol withcolor 0.8yellow ;
trace_euro := true ; draw euro_symbol shifted (5cm,0) ;
\stopuseMPgraphic

\useMPgraphic{dummy}
\stoptext

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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