12

I have some special delimiters that I want to add to a glossary, those get hyperlinks and colors etc. However when i want to use those delimiters, using \left, \right and \middle becomes impossible. I think with the following question fixed I can create my hyperlinked delimiters:

How to color delimiters:

As a minimal working example I have:

$\left\textcolor{red}{(}a\right)$

What i would like to have is (Created without \left \right):

Color

This gets the error: ! Missing delimiter (. inserted).


Trying this :

$\textcolor{red}{\left(}a\right)$

results in ! Extra }, or forgotten \right.

Who can help me?

Paulo Cereda
  • 44,220

2 Answers2

13

use it this way:

$\color{red}\left(\normalcolor a\right)$

or

$\textcolor{red}{\big(} a\big)$

There a \big, \bigg, \Big, and \Bigg

  • this will not work if the current color is not the \normalcolor. And as I want to use this in a command, this will not work for me. And put this in a hyperlink will not work with this solution. – Rubix Cube Jul 11 '12 at 12:02
  • then you can only use \big et al (see edit). –  Jul 11 '12 at 12:06
  • However, i do not want the delimiters to be big :) They should fit, that is why I want to use \left and \right – Rubix Cube Jul 11 '12 at 15:49
11

Here is macro that can easily be extended to different styles of brackets:

enter image description here

Notes:

Code:

\documentclass{article}
\usepackage{xcolor}

\newcommand{\BracKern}{\kern-\nulldelimiterspace} \makeatletter \newcommand{@Brac}[3]{% #1,#3 = left/right bracket type
\mathopen{\color{red}\left#1\vphantom{#2}\BracKern\right.}% left bracket #2% content \mathclose{\left.\BracKern\vphantom{#2}\right#3}% right bracket } \newcommand{\bracr}[1]{@Brac{(}{#1}{)}}% \newcommand{\bracs}[1]{@Brac{[}{#1}{]}}% \newcommand{\bracc}[1]{@Brac{{}{#1}{}}}% \makeatother

\begin{document} $\bracr{a}$ $\displaystyle\bracr{\frac{1}{2}}$ $\bracs{a}$ $\displaystyle\bracs{\frac{1}{2}}$ $\bracc{a}$ $\displaystyle\bracc{\frac{1}{2}}$ \end{document}

Peter Grill
  • 223,288