7

I want to put curly braces around an image that is about 3.5 x 5 inches. When I do this using the following command, the braces are 5 inches tall but very skinny, so it looks bad.

 \newcommand{\bracedincludegraphics}[2][]{%
 \sbox0{$\vcenter{\hbox{\includegraphics[#1]{#2}}}$}%

   \left\lbrace

   \vphantom{\copy0}
   \right.\kern-\nulldelimiterspace

   \rbrace{\box0}}

How do I make the curly braces thicker and wider. By "wider," I mean that the horizontal length from the one point on the left of \lbrace to the two points on the top and bottom of \lbrace is too small (and the analogous situation for \rbrace). Basically I want it to be noticeable that a 3.5 x 5 inch graphic is between curly braces, instead of the braces looking scrawny. As an example of this, look at the TeX stack exchange logo. The thickness of those braces would be very nice, if not thicker. Thanks.

Sebastiano
  • 54,118
Casey
  • 71
  • why all the boxing and phantoms, not just something like \left\{\vcenter{\hbox{\includegraphics{..}}}\right\} which would put the graphic between the braces, you have a stretching left brace and a non stretching right brace, both to the left of the box? – David Carlisle Jun 07 '17 at 18:16
  • To get something approaching the TeX Logo, you should look at https://tex.stackexchange.com/q/85050/86 (But there are simpler variants, I'll post one in a moment). – Andrew Stacey Jun 07 '17 at 18:26

4 Answers4

7

If you're prepared to load TikZ, here's a version using the calligraphy package.

\documentclass{article}
%\url{https://tex.stackexchange.com/q/373803/86}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,calligraphy}


\begin{document}

\tikz {\node (a) {\includegraphics[width=.8\textwidth]{batman}}; \draw[decorate,line width=5mm,decoration={calligraphic brace, amplitude=1cm}] (a.north east) -- (a.south east); \draw[line width=5mm,decorate,decoration={calligraphic brace,amplitude=1cm}] (a.south west) -- (a.north west); }

\end{document}

Obviously, you could package all that into a command. I've picked the numbers to show the effect, you can vary them as you please.

image with braces

Andrew Stacey
  • 153,724
  • 43
  • 389
  • 751
5

enter image description here

\documentclass[landscape]{article}
\addtolength\oddsidemargin{-1in}
\addtolength\textwidth{2in}
\usepackage{graphicx}

\begin{document}

\begin{center}

\raisebox{-.32\height}{\resizebox*{!}{5in}{\{}}%
\raisebox{-.5\height}{\includegraphics[width=3.5in,height=5in]{example-image}}%
\raisebox{-.32\height}{\resizebox*{!}{5in}{\}}}%


\end{center}


\end{document}
David Carlisle
  • 757,742
3

The following is a little more precise that David's answer, making the height of the resulting image construction exactly 5". We place {<img>} (a small <img>) in a box and resize it to have a height of 5".

enter image description here

\documentclass{article}

\usepackage[landscape,paper=a4paper,margin=5mm]{geometry}% Just for this example
\usepackage{graphicx}

\begin{document}

\resizebox{!}{5in}{% Resulting content will be exactly 5in tall
  \raisebox{\depth}{$\bigl\{$}%
  \includegraphics[height=\baselineskip]{example-image}%
  \raisebox{\depth}{$\bigr\}$}%
}

\end{document}
Werner
  • 603,163
0

As one might expect, ConTeXt has inbuilt support for this. In particular, brace is a framed fence in ConTeXt, which means that one can set it as topframe, leftframe, rightframe, or bottomframe or a \framed. The brace is actually drawn using metapost.

Here is a code that illustrates the usage:

\useMPlibrary[fen] % For the brace fence
\useMPlibrary[dum] % For a random graphic

\defineframed[braceframe]
             [
               frame=off,
               leftframe=brace,
               rightframe=brace,
               loffset=3em,
               roffset=3em,
               framecolor=darkblue,
             ]

\starttext
\braceframe{\externalfigure[dummy][width=5in, height=3.5in]}
\stoptext

which gives

enter image description here

Aditya
  • 62,301