# Side brace around image with underbrace

I have an image and I want to put a side brace on the left and an underbrace on the bottom. The underbrace works fine, but the left becomes twice the image height for some reason. I'm sure the image isn't actually that big, I've looked at the pixel height. Is this the wrong way to do it?

$r\left\{\underbrace{\includegraphics{image1.jpg}}_{k/r}\right.$

-

You have to center the picture with respect to the math axis: but it's best to define a personal command for this

\documentclass{article}
\usepackage{graphicx}

\newcommand{\bracedincludegraphics}[2][]{%
\sbox0{$\vcenter{\hbox{\includegraphics[#1]{#2}}}$}%
\left\lbrace
\vphantom{\copy0}
\right.\kern-\nulldelimiterspace
\underbrace{\box0}}

\begin{document}
$r\bracedincludegraphics{image1}$
\end{document}


The command \bracedincludegraphics accepts the same options as \includegraphics.

I set the image in a box for later use, centered with respect to the math axis (that's the main problem with your try, as the image has all height and no depth, and \left assumes that it has to cover as much over the math axis as below).

Then I use the box to determine the size of the left brace with a \vphantom, close with \right. and kern back a bit; only after this I typeset the image with the underbrace.

## EDIT

In order to add a small clearance also between the underbrace and the image, the following modified macro should help:

\newcommand{\bracedincludegraphics}[2][]{%
\sbox0{$\vcenter{\hbox{\includegraphics[#1]{#2}}}$}%
\left\lbrace
\vphantom{\copy0}
\right.\kern-\nulldelimiterspace
\underbrace{\vrule width0pt depth \dimexpr\dp0 + .3ex\relax\box0}}


The .3ex should be what's needed, but it depends on the font actually used for math.

-

You can use tikz.

\documentclass[10pt,a4paper,parskip]{scrbook}
%\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
%
\PreviewEnvironment{tikzpicture}
\usetikzlibrary{decorations.pathreplacing}
%
\begin{document}
%
\begin{tikzpicture}

\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=0.9\textwidth]{image1.jpg}};
%
%To scale the dimensions of brace in case if image is scaled in future
%
\begin{scope}[x={(image.south east)},y={(image.north west)}]
%
%Draw grids for identifying the points easily
\draw[help lines,xstep=.1,ystep=.1] (0,0) grid (1,1);
\foreach \x in {0,1,...,9} { \node [anchor=north] at (\x/10,0) {0.\x}; }
\foreach \y in {0,1,...,9} { \node [anchor=east] at (0,\y/10) {0.\y}; }
% Draw the braces
\draw[decorate, decoration={brace, amplitude=5pt}] (1,-0.1)--(0,-0.1);
\draw[decorate, decoration={brace, amplitude=5pt}] (-0.07,0)--(-0.07,1);
%
\end{scope}
%
\end{tikzpicture}
%
\end{document}


-
For a more compact solution, you can also use the matrix library and use left delimiter and below delimiter. – percusse Feb 12 '12 at 23:55