1

Lets consider two silimar boxed environments using mdframed and tcolorbox, processed by xelatex/pdflatex:

\documentclass{article}
\usepackage{tcolorbox}
\usepackage{mdframed}
\usepackage{lipsum}

\begin{document}
\begin{tcolorbox}[colback=white,colframe=black,sharp corners=all,boxrule=0.7pt,top=0.2in]
\lipsum[3]
\end{tcolorbox}

\begin{mdframed}[linewidth=0.7pt,innertopmargin=0.2in,innerbottommargin=0.2in]
\lipsum[3]
\end{mdframed}

\end{document}

On zoom 100% or greater we see two equivalent boxes in all PDF viewers (Evince, Okular, Adobe Acrobat, …)

But on zoom below 75% tcolorbox starts to loose frame borders on Okular and Adobe Acrobat.

This PDF on 66% in Adobe Reader DC

This PDF on Okular on some zoom below 100%

Yes, questions already discussed [Box border lines not showing properly on PDF ], (about incorrect rasterization in Evince, guilty PDF viewers, etc).

But I see, that mdframed hacked somehow this problem and "mdframed borders" OK in all PDF Viewers (even without "[framemethod=tikz]").

Is it possible to specify some magic options/hack/workaround to make tcolorbox behave "like mdframed"? ("save borders in all zoom levels even in Okular and Adobe Reader")

  • Believe me, this is an PDF viewer issue. I often don't see frames of mdframed boxes at the same resolution where borders from tcolorbox are visible – user31729 Jan 30 '17 at 19:10
  • I also did not see frames on old (1.6) versions on mdframed, but since mdframed 1.9 all always see frames on all zoom levels... in Okular/Adobe. – Stas Fomin Jan 30 '17 at 19:14
  • The difference is that the tcolorbox one is filled (with white) and the border is getting overprinted at some zoom levels (which is hard to stop) the mdframed one isn't filled so the borders are more robust. It should be possible to tell tcolorbox not to fill but I don't see anything just now if you omit the colback=whit you get a default fill... – David Carlisle Jan 30 '17 at 19:14
  • 1
    Thank to @DavidCarlisle! The problem is in filling! \begin{tcolorbox}[standard jigsaw,opacityback=0,colframe=black,sharp corners=all,boxrule=0.7pt,top=0.2in,left=0.1in] works for me! – Stas Fomin Jan 30 '17 at 19:26
  • 1
    @StasFomin oh I failed to juggle the keys into the right order, can you self answer:-) – David Carlisle Jan 30 '17 at 19:29
2

The problem with tcolorbox is a mess with rasterizing both borders and fill background (thanks @DavidCarlishe). We need transparent background in tcolor box.

Corrected source:

\documentclass{article}
\usepackage{tcolorbox}
%\tcbuselibrary{skins}
\usepackage{mdframed}
\usepackage{lipsum}

\begin{document}
\begin{tcolorbox}[standard jigsaw,opacityback=0,colframe=black,sharp corners=all,boxrule=0.7pt,top=0.2in,left=0.1in]
\lipsum[3]
\end{tcolorbox}

\begin{mdframed}[linewidth=0.7pt,innertopmargin=0.2in,innerbottommargin=0.2in]
\lipsum[3]
\end{mdframed}

\end{document}

OK with all zoom levels in Okular and Adobe Acrobat.

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.