1

I'd like a simple black border around my images:

\documentclass{article}
\usepackage{graphicx}
\usepackage{calc}
\usepackage{mwe}
\setlength{\parindent}{0pt}
\setlength{\fboxsep}{0pt}
\begin{document}
    \includegraphics[width=\linewidth]{example-image}\\
    \fbox{\includegraphics[width=\linewidth - 2\fboxrule - 2\fboxsep]{example-image}}
\end{document}

This is working fine, except when zooming in. In the bottom image, you see a faint line between the image and the border:

enter image description here

I see this in a number of PDF viewer (Acrobat Reader on Windows, Google Chrome on Windows, pdf.js on Linux). I had though that I could solve this using a black background within the border, but I see the same artifacts:

\documentclass{article}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{calc}
\usepackage{mwe}
\setlength{\parindent}{0pt}
\setlength{\fboxsep}{0pt}
\begin{document}
    \includegraphics[width=\linewidth]{example-image}\\
    \fcolorbox{black}{black}{\includegraphics[width=\linewidth - 2\fboxrule - 2\fboxsep]{example-image}}
\end{document}

Can I avoid this?

0
2

You could avoid drawing a frame and just draw a single rule behind the image, either directly with \rule or using \colorbox as here

enter image description here

\documentclass{article}
\usepackage{graphicx}
\usepackage{xcolor}

\setlength{\parindent}{0pt}
\setlength{\parskip}{20pt}
\addtolength\textheight{15cm}
\addtolength\paperheight{5cm}

\begin{document}
    \includegraphics[width=\linewidth]{example-image}

{
\setlength{\fboxsep}{0pt}

\fcolorbox{black}{black}{\includegraphics[width=\dimexpr\linewidth - 2\fboxrule - 2\fboxsep]{example-image}}

}

{
  \setlength{\fboxsep}{2pt}

\colorbox{black}{\includegraphics[width=\dimexpr\linewidth - 2\fboxsep]{example-image}}

}


\end{document}

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.