3

In my document I want the fcolorbox the same width as the graphics, but I can't get it right. The left side is aligned (wich is good) but the right side is not (which is bad ...)

What is going wrong here?

\documentclass[11pt,landscape,twoside]{article}
\usepackage[english,dutch]{babel}
\usepackage{multicol}
\usepackage{xcolor}
\usepackage{graphicx}
\graphicspath{{../graph/}{../tek/}}

\begin{document}
\begin{multicols}{3}

\parbox[t]{1.0\linewidth}{
    \includegraphics[width=1.0\linewidth]{joec.jpg}\hfill
    \vspace{-5.0pt}
    \fcolorbox{gray}{gray}{\parbox{1.0\linewidth-2\fboxsep-2\fboxrule}{
                        \color{white}
                        \raggedleft{\small{text text text} }
                    }
                }
}
\end{multicols}
\end{document}
Mensch
  • 65,388

1 Answers1

3

Spurious blank spaces (I removed them in my code by deleting some and some others using %); you were missing \dimexpr in the calculation of the \parbox width:

\documentclass[11pt,landscape,twoside]{article}
\usepackage[english,dutch]{babel}
\usepackage{multicol}
\usepackage{xcolor}
\usepackage[demo]{graphicx}
\graphicspath{{../graph/}{../tek/}}

\begin{document}
\begin{multicols}{3}
\noindent\parbox[t]{1.0\linewidth}{%
\includegraphics[width=1.0\linewidth]{joec.jpg}\hfill\par\nointerlineskip
\fcolorbox{gray}{gray}{%
  \parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}{\color{white}%
  \raggedleft{\small text text text}
  }%
}%
}
\end{multicols}
\end{document}

enter image description here

The demo option for graphicx simply replaces actual figures with black rectangles; do not use that option in your actual document.

Gonzalo Medina
  • 505,128
  • Thanx, this solved my problem, but raised another question which was solved by this answer: [http://tex.stackexchange.com/questions/7453/what-is-the-use-of-percent-signs-at-the-end-of-lines] – Gerco-Kees Apr 18 '13 at 19:24