2

I am trying to make a semi transparent color framed box with \fcolorbox. It seems that the rules that make up the frame overlap. Is there a way to make a framebox like the one shown in the MWE below but with a consistent gray color? In my real use case the box is overlaying other text so needs to be transparent. Ideally, I would be able to control the transparency of the edges and fill separately.

\documentclass{article}
\usepackage{transparent}
\usepackage{xcolor}
\begin{document}
\setlength{\fboxrule}{20pt}
\transparent{0.5}%
\fcolorbox{black}{red}{\transparent{1.0}Hello World}
\end{document}

enter image description here

  • 2
    My usual comment: Use tcolorbox or mdframed and the TikZ facilities, however, transparent does not work with tcolorbox, but I think the cause of the overlapping is the way how the box rules are drawn – user31729 Jan 5 '17 at 19:35
  • @ChristianHupfer Slight overkill here, though? ;) – cfr Jan 6 '17 at 1:23
2

efbox provides an enhanced version of \fbox{} and friends, which seems to work fine with the transparency settings. For example:

\documentclass{article}
\usepackage{transparent}
\usepackage{xcolor}
\usepackage{efbox}
\begin{document}
\setlength{\fboxrule}{20pt}
\transparent{0.5}%
\efbox[backgroundcolor=red]{Hello World}
\efbox[backgroundcolor=red]{\transparent{1.0}Hello World}
\end{document}

slightly fancier boxes

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.