11
$\begingroup$

12.0.0 for Microsoft Windows (64-bit) (April 6, 2019)

How do I get my graphic to look the same in PDF as it does in a Notebook?

This is what the graphic looks like in the FrontEnd:

enter image description here

This is how the same image appears in a PDF file:

enter image description here

This is the code producing the graphics.

    Module[{arc, \[GothicC]a, \[GothicC]b, \[GothicC]c, \
\[ScriptCapitalC]a, \[ScriptCapitalC]b, \[ScriptCapitalC]c, \[Theta]a \
= 2/3 \[Pi], \[Theta]b = 4/3 \[Pi], \[Theta]c = 0
  , \[CapitalTheta], \[CapitalDelta]\[CapitalTheta]
  , \[CapitalDelta]\[Theta]1 = \[Pi], \[CapitalDelta]\[Theta]2 = \
\[Pi]/3, \[GothicCapitalR]}
 , \[GothicC]a = {0, 0}; \[GothicC]b = {1, 
   0}; \[GothicC]c = \[GothicC]b/
   2 + {0, 1} Sqrt[3]/
    2; \[GothicCapitalR][\[Theta]_] := {Cos[\[Theta]], Sin[\[Theta]]};
 arc[\[GothicC]_, \[Theta]_, \[CapitalDelta]\[Theta]_] := (\[GothicC] \
+ \[GothicCapitalR][#]) & /@ 
   Range[\[Theta], \[Theta] + \[CapitalDelta]\[Theta], \
\[CapitalDelta]\[Theta]/180];
 \[CapitalDelta]\[CapitalTheta] = {0, \[Pi], 4/3 \[Pi], 5/3 \[Pi]};
 \[CapitalTheta][\[Theta]_, 
   i_] := \[Theta] + \[CapitalDelta]\[CapitalTheta][[i]];
 
 \[ScriptCapitalC]a = {arc[\[GothicC]a, \[CapitalTheta][\[Theta]a, 
     1], \[CapitalDelta]\[Theta]1], 
   arc[\[GothicC]a, \[CapitalTheta][\[Theta]a, 
     2], \[CapitalDelta]\[Theta]2], 
   arc[\[GothicC]a, \[CapitalTheta][\[Theta]a, 
     3], \[CapitalDelta]\[Theta]2], 
   arc[\[GothicC]a, \[CapitalTheta][\[Theta]a, 
     4], \[CapitalDelta]\[Theta]2]};
 \[ScriptCapitalC]b = {arc[\[GothicC]b, \[CapitalTheta][\[Theta]b, 
     1], \[CapitalDelta]\[Theta]1], 
   arc[\[GothicC]b, \[CapitalTheta][\[Theta]b, 
     2], \[CapitalDelta]\[Theta]2], 
   arc[\[GothicC]b, \[CapitalTheta][\[Theta]b, 
     3], \[CapitalDelta]\[Theta]2], 
   arc[\[GothicC]b, \[CapitalTheta][\[Theta]b, 
     4], \[CapitalDelta]\[Theta]2]};
 \[ScriptCapitalC]c = {arc[\[GothicC]c, \[CapitalTheta][\[Theta]c, 
     1], \[CapitalDelta]\[Theta]1], 
   arc[\[GothicC]c, \[CapitalTheta][\[Theta]c, 
     2], \[CapitalDelta]\[Theta]2], 
   arc[\[GothicC]c, \[CapitalTheta][\[Theta]c, 
     3], \[CapitalDelta]\[Theta]2], 
   arc[\[GothicC]c, \[CapitalTheta][\[Theta]c, 
     4], \[CapitalDelta]\[Theta]2]};
 
 Graphics[{Thickness[0.02], 
   Point[{\[GothicC]a, \[GothicC]b, \[GothicC]c}]
   , {Red, Line[\[ScriptCapitalC]a[[1]]], 
    Point[\[GothicC]a + \[GothicCapitalR][\[CapitalTheta][\[Theta]a, 
        1]]]}
   , {Blue, Line[\[ScriptCapitalC]a[[2]]]}
   , {Green, Line[\[ScriptCapitalC]a[[3]]]}
   , {Magenta, Line[\[ScriptCapitalC]a[[4]]]}
   , {Red, Line[\[ScriptCapitalC]b[[1]]]}
   , {Blue, Line[\[ScriptCapitalC]b[[2]]]}
   , {Green, Line[\[ScriptCapitalC]b[[3]]]}
   , {Magenta, Line[\[ScriptCapitalC]b[[4]]]}
   , {Red, Line[\[ScriptCapitalC]c[[1]]]}
   , {Blue, Line[\[ScriptCapitalC]c[[2]]]}
   , {Green, Line[\[ScriptCapitalC]c[[3]]]}
   , {Magenta, Line[\[ScriptCapitalC]c[[4]]]}
   , {Blue
    , Polygon[
     Join[\[ScriptCapitalC]a[[1]], \[ScriptCapitalC]b[[
       4]], \[ScriptCapitalC]c[[2]]]]
    , Polygon[
     Join[\[ScriptCapitalC]b[[1]], \[ScriptCapitalC]c[[
       4]], \[ScriptCapitalC]a[[2]]]]
    , Polygon[
     Join[\[ScriptCapitalC]c[[1]], \[ScriptCapitalC]a[[
       4]], \[ScriptCapitalC]b[[2]]]]
    , Polygon[
     Join[\[ScriptCapitalC]c[[3]], \[ScriptCapitalC]a[[
       3]], \[ScriptCapitalC]b[[3]]]]
    }
   }]
 ]
$\endgroup$
5
  • 2
    $\begingroup$ I reproduce your problem in v12, and it's even worse in v12.1: imgur.com/a/WpLnqWS $\endgroup$ – MelaGo Jan 11 at 1:09
  • 2
    $\begingroup$ That's what I'm good at. Breaking stuff. $\endgroup$ – Steven Thomas Hatton Jan 11 at 4:24
  • $\begingroup$ Seems to me like MMA's PDF writer is pretty good at breaking stuff... $\endgroup$ – MelaGo Jan 11 at 4:56
  • $\begingroup$ Please report this to Support. $\endgroup$ – J. M.'s ennui Jan 11 at 7:32
  • $\begingroup$ No problem with this graphics in the PDF produced by Mathematica 8.0.4, the PDF looks identically to the FrontEnd. It would be nice to check it using versions 9, 10 and 11, if someone has access. $\endgroup$ – innaiz Jan 11 at 10:41
15
$\begingroup$

It seems like there are two main problems.

One is the shape of the polygons

test = Graphics@Polygon[Join[\[ScriptCapitalC]a[[1]], \[ScriptCapitalC]b[[4]], \
\[ScriptCapitalC]c[[2]]]]

enter image description here

Gives this in the PDF:

enter image description here

Plotting the points gives a clue to why:

ListPlot[Join[\[ScriptCapitalC]a[[1]], \[ScriptCapitalC]b[[4]], \
\[ScriptCapitalC]c[[2]]], Joined -> True, AspectRatio -> Automatic]

enter image description here

Changing the order of some points helps:

ListPlot[Join[\[ScriptCapitalC]a[[1]], 
  Reverse@\[ScriptCapitalC]b[[4]], Reverse@\[ScriptCapitalC]c[[2]]], 
 Joined -> True, AspectRatio -> Automatic]

enter image description here

And

test2 = Graphics@Polygon[Join[\[ScriptCapitalC]a[[1]], 
    Reverse@\[ScriptCapitalC]b[[4]], Reverse@\[ScriptCapitalC]c[[2]]]]

Gives the expected PDF:

enter image description here

The other main problem is that the lines are hidden. This can be fixed by drawing the lines after the polygons.

Using both of these workarounds:

Graphics[{
  {Blue, Polygon[
    Join[\[ScriptCapitalC]a[[1]], Reverse@\[ScriptCapitalC]b[[4]], Reverse@\[ScriptCapitalC]c[[2]]]], Polygon[Join[\[ScriptCapitalC]b[[1]], Reverse@\[ScriptCapitalC]c[[4]], Reverse@\[ScriptCapitalC]a[[2]]]], 
   Polygon[Join[\[ScriptCapitalC]c[[1]], Reverse@\[ScriptCapitalC]a[[4]], Reverse@\[ScriptCapitalC]b[[2]]]], Polygon[Join[\[ScriptCapitalC]c[[3]], \[ScriptCapitalC]a[[3]], \
\[ScriptCapitalC]b[[3]]]]},
  Thickness[0.01], Point[{\[GothicC]a, \[GothicC]b, \[GothicC]c}], {Red, Line[\[ScriptCapitalC]a[[1]]], Point[\[GothicC]a + \[GothicCapitalR][\[CapitalTheta][\[Theta]a, 
       1]]]}, {Blue, Line[\[ScriptCapitalC]a[[2]]]}, {Green, Line[\[ScriptCapitalC]a[[3]]]}, {Magenta, Line[\[ScriptCapitalC]a[[4]]]}, {Red, Line[\[ScriptCapitalC]b[[1]]]}, {Blue, Line[\[ScriptCapitalC]b[[2]]]}, {Green, Line[\[ScriptCapitalC]b[[3]]]}, {Magenta, Line[\[ScriptCapitalC]b[[4]]]}, {Red, Line[\[ScriptCapitalC]c[[1]]]}, {Blue, Line[\[ScriptCapitalC]c[[2]]]}, {Green, Line[\[ScriptCapitalC]c[[3]]]}, {Magenta, Line[\[ScriptCapitalC]c[[4]]]}
  }]

enter image description here

Gives PDF:

enter image description here

$\endgroup$

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.