Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

use it this way:

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

or

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

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

share|improve this answer
    
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. –  J. van Hoorn Jul 11 '12 at 12:02
    
then you can only use \big et al (see edit). –  Herbert 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 –  J. van Hoorn Jul 11 '12 at 15:49

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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.