issue also opened at https://github.com/texstudio-org/texstudio/issues/51

When I compile this MWE latex file in texstudio, on windows, using MikTex, then view the result using texstudio internal PDF viewer, it shows white streak lines going over the image. These lines are not in the original image.

Also these lines do not show up when I view the compiled PDF file using external PDF reader such as adobe.

Why is that? The image is also a PDF file. Is it possible to resolve it? It is not a big issue really, since this seems to be just an artifact of texstudio pdf viewer itself, but thought to ask if there is an option to fix this.

Here is MWE

This is my image, as PDF file, imported using includegraphics


I put the file image.pdf is on my web page here

This is how the compiled PDF looks like inside texstudio PDF viewer

Mathematica graphics

This is how the PDF looks like inside adobe PRO pdf reader

Mathematica graphics

Notice the white lines that show up in texstudio. This is pdfinfo on the image file

pdfinfo image.pdf 

Creator:        Wolfram Mathematica for Microsoft Windows (64-bit) (September 10, 2017) Student Edition - Personal Use Only
CreationDate:   Sat Mar  3 16:13:39 2018
ModDate:        Sat Mar  3 16:13:39 2018
Tagged:         no
UserProperties: no
Suspects:       no
Form:           none
JavaScript:     no
Pages:          1
Encrypted:      no
Page size:      470 x 367 pts
Page rot:       0
File size:      99049 bytes
Optimized:      no
PDF version:    1.5

I am using

TeXstudio 2.12.6 (hg 6632:7777b2b8a906)
Using Qt Version 5.9.1, compiled with Qt 5.9.1 R

Windows 7.

  • 2
    You should open an issue here --> github.com/texstudio-org/texstudio/issues
    – DG'
    Mar 3, 2018 at 22:32
  • 3
    Such reports are best communicated directly to the devs. Just out of curiosity, do the white lines still show up when you zoom in?
    – Troy
    Mar 3, 2018 at 22:35
  • 1
    No idea how to fix this, but the reason the image works in adobe reader is that it has the option "enhance thin lines" enabled as default. Mar 4, 2018 at 0:06
  • I don't know which tool you use to plot your data, but from how your data looks like, you could also try to reduce the number of contour from 100 to 15 (or how many steps you have in the colour bar). If your plotting tool is clever it will create bigger continuous objects instead of drawing each bin separately. Mar 4, 2018 at 0:49
  • 3
    I'm voting to reopen this question, because (1) this is an issue that comes up quite frequently with pdf/eps images, (2) there is a good chance of an answer here (in fact 100%, since I know how to fix the problem), and (3) there is no other obvious place for (La)TeX users to ask for help with this. Apr 10, 2018 at 14:16

3 Answers 3


This is an issue which was common to several versions of Mathematica, though strangely I can't reproduce it using Mathematica 11 (on Linux, not Windows). It happens when vector graphics are shaded using polygons (as is the case here), but the outlines of the polygons are omitted. To fix the issue, export your image as eps (you can convert to pdf later), by enclosing your ContourPlot command in an Export command:

Export[ "myfile.eps" , Contourplot[ ... ] ] 

Then, open up the eps file in your favourite text editor, and find the macro which is used to fill polygons. This will be near the top of the file, and will probably be something like

/f { fill bind def }

or perhaps

/f fill load def

Change fill to gsave fill grestore stroke and save the file. The new instruction tells the viewer to shade the polygons and draw their outlines. After reloading in your viewer, you should find that the issue is gone.

  • Just in case the image is already saved as pdf, conversion can be done with pdf2ps filename.pdf ; ps2eps filename.ps. For converting back to pdf: epspdf filename.eps Apr 10, 2018 at 16:06
  • If the problem occurs in pdfs produces by root, edit the /f* function rather than /f. Apr 10, 2018 at 16:07
  • is this something different than problem one can see from \hsize2cm \leavevmode\hrule height 3pt \hrule height 3pt <repeat 10 times> \nopagenumbers\bye in Plain TeX. With pdfTeX, depends on pdf viewer. (shows up also in acroread on my mac os depends on magnification)
    – user4686
    Apr 10, 2018 at 18:16

The image is composed of triangles. The following image is generated from the PDF file. First the page stream of the file is uncompressed by:

 pdftk image.pdf cat output image-uncompress.pdf uncompress

Then the file is modified by replacing " m B" by " m S" and " m f" by " m S". The replacement of B and f by S removes the filling and the triangles are drawn only.

enter image description here

As can be seen the white lines collide with borders between triangles. Thus, maybe it is a rounding issue.


My usual approach to circumvent this problem is to export such images in multiple layers.

  • One layer which only contains the coloured histogram, no axis nore text. This file will be saved as .png thus circumventing the viewer artefacts at the edges of bins.

enter image description here

  • The next layer contains all lines and text. This layer will be saved as .pdf

enter image description here

  • Both layers can be combined in several ways. You could use inkscape or directly do it in latex and use a picture environment to stack the images.

enter image description here

(For histograms with a very large number of bins, this approach will also dramatically reduce the file size and speeds up rendering of the .pdf)

  • Slightly related: When I look at user forms for writers, in print-on-demand, I often seen that there are issues with vector artwork. This has nothing to do with TeX; the writers are using other software. It is the nature of vector images in PDF. The best solutions involve rasterizing the images, so there is no vector component at all, not even overlying text. Fortunately, the documents are printed to paper at a fixed size, so there is no need to maintain scalable graphics.
    – user139954
    Apr 10, 2018 at 15:53
  • @RobtAll Rasterizing the whole image including the text would only be my very last resort. This bereaves every possibility to adjust the font to the one used in the document etc. I also think that most documents are not being printed but distributed digitally. Apr 10, 2018 at 15:59
  • OK, I see that. My own application involves final conversion to CMYK, which must be flat, and involves things such as knockouts, etc.
    – user139954
    Apr 10, 2018 at 16:00
  • @samcarter --- Are you willing to share the Mathematica code that splits contour plots in this way? It might be useful to me in cases where the eps file is very large, and cannot be reduced sufficiently by polygone. Thanks for the bounty, by the way. Apr 13, 2018 at 9:18
  • @IanThompson Sorry, I don't use Mathematica. I produced the example in my answer by editing the pdf provided by the OP. I could provide root code (root.cern.ch) that exports histograms in different layers, if this would be any help? And you're welcome! gsave fill grestore stroke is really useful to know! Apr 13, 2018 at 9:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .