TeX - LaTeX Asked by Iván Vega on June 13, 2021
I’m trying to insert an image with a rectangular border, and that rectangular border has a gray color, something like this:
This is my code:
begin{figure}
lineskip=-fboxrule
textcolor{Orange}{
colorbox{Gray}{
fbox{begin{minipage}{dimexprtextwidth-2fboxsep-2fboxrule}
centering
includegraphics{imagenes/ejemplo_cubo_OLAP.png}
abovecaptionskip=0pt
textcolor{Gris}{caption{sffamily{textbf{The caption text}}}}
end{minipage}
}
}
}
end{figure}
And the result I get is this:
As you can see, the gray fill is spilling over the edge, and that’s what I want to avoid.
Keep in mind that I am very new to Latex
Like this?
With use of the tikz
package and example-image-duck
instead of original image, which is not available to us:
documentclass{article}
usepackage{tikz}
tikzset{
figframe/.style = {
draw=orange, very thick, fill= gray!30,
minimum width=linewidth, inner sep=2mm,
text width= pgfkeysvalueof{/pgf/minimum width} -
2*pgfkeysvalueof{/pgf/inner xsep},
align=center}
}
usepackage{graphicx}
usepackage[font={small, bf, sf}]{caption}
begin{document}
begin{figure}
tikz{node [figframe]{
includegraphics{example-image-duck}%{imagenes/ejemplo_cubo_OLAP.png}
caption{The caption text}
};
}
end{figure}
end{document}
Answered by Zarko on June 13, 2021
Why not simply a parbox
in a fcolorbox
?
documentclass{article}
usepackage{graphicx,xcolor,lipsum}
begin{document}
lipsum[1][1-3]
begin{figure}[h]fboxrule3ptfboxsep2em
fcolorbox{orange}{lightgray}{%
parbox{dimexprlinewidth-2fboxsep-2fboxrule}{centering%
includegraphics[width=.8linewidth]{example-image}%
caption{lipsum[2][1-2]}}}
end{figure}
lipsum[1][4-8]
end{document}
Answered by Fran on June 13, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP