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?

2 Answers 2

13

use it this way:

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

or

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

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

3
  • 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, 2012 at 12:02
  • then you can only use \big et al (see edit).
    – user2478
    Jul 11, 2012 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, 2012 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}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .