Featured Book

LaTeX Beginners Guide

Who is online

In total there are 5 users online :: 0 registered, 0 hidden and 5 guests (based on users active over the past 5 minutes)
Most users ever online was 1327 on Tue Nov 05, 2013 7:11 pm

Users browsing this forum: No registered users and 5 guests

Partner Sites

TeXwelt - Fragen und Antworten goLaTeX
TeXblog
TeXnicCenter
TeXample

Thinner Braces in Math Mode Topic is solved

Add tags Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).

Thinner Braces in Math Mode

Postby Cham on Sun Nov 18th, 2012

The \underbrace and \overbrace commands are really useful, but they are ugly. I would like to have thinner braces. Is this possible ?

Here's a compilable example :
Code: Select all  •  Open in writeLaTeX
\documentclass[12pt,letterpaper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\begin{document}
  Test with braces :
  \begin{equation}
    \underbrace{ABCD}_{\text{this is a test}} + DEFG = \overbrace{HIJK}^{\text{this is a test}}
 
\end{equation}
\end{document
}
User avatar
Cham
 
Posts: 411
Joined: Sat Apr 2nd, 2011

Re: Thinner Braces in Math Mode

Postby cgnieder on Sun Nov 18th, 2012

This is depending on the math font you use and the way the braces are built (see here for example). So if you choose a different math font you'll probably get different braces which you might like better.

An example:
Code: Select all  •  Open in writeLaTeX
\documentclass[12pt,letterpaper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{newtxtext}
\usepackage{newtxmath}
\begin{document}
Test with braces:
\begin{equation}
 \underbrace{ABCD}_{\text{this is a test}} + DEFG = \overbrace{HIJK}^{\text{this is a test}}
\end{equation}

\end{document
}


braces.png
braces.png (7.82 KiB) Viewed 1354 times


Regards
Last edited by cgnieder on Sun Nov 18th, 2012, edited 2 times in total.
Reason: added example + image
Clemens
------------------------------
New German Q&A site about TeX: http://texwelt.de/wissen
System: TeXlive 2013, OpenSUSE 12.3
User avatar
cgnieder
Site Moderator
 
Posts: 1696
Joined: Sat Apr 16th, 2011
Location: Germany

Re: Thinner Braces in Math Mode

Postby Cham on Sun Nov 18th, 2012

The newtxtext and newtxmath packages are giving me a compilation error.

If I keep the same fonts as in my example above, is there a way to modify the underbrace and overbrace commands, so they give a nicer (thinner, slimmer) horizontal brace ?

EDIT : By nicer horizontal braces, I mean that the line thickness should be much smaller. Something graceful, not that heavy thick line we currently have.
User avatar
Cham
 
Posts: 411
Joined: Sat Apr 2nd, 2011

Re: Thinner Braces in Math Mode

Postby hugovdberg on Sun Nov 18th, 2012

You should probably install the newtx package from ctan. Depending on your latex distribution there are different ways to install them.
Ubuntu 13.10 + Tex Live 2013 + Texmaker / Windows 7 Pro + MikTex 2.9 + TexnicCenter / Android 4.3 + TexPortal + DroidEdit
hugovdberg
 
Posts: 133
Joined: Sat Feb 25th, 2012
Location: 's-Hertogenbosch, Netherlands

Re: Thinner Braces in Math Mode

Postby cgnieder on Sun Nov 18th, 2012

hugovdberg wrote:You should probably install the newtx package from ctan.


My thoughts exactly. The best way would be updating the TeX distribution by using the corresponding package manager. Installing fonts and fonts packages by hand can be a tedious task.

Regards
Clemens
------------------------------
New German Q&A site about TeX: http://texwelt.de/wissen
System: TeXlive 2013, OpenSUSE 12.3
User avatar
cgnieder
Site Moderator
 
Posts: 1696
Joined: Sat Apr 16th, 2011
Location: Germany

Re: Thinner Braces in Math Mode

Postby Cham on Sun Nov 18th, 2012

Ok about the newtx package, but what about the braces without changing the fonts ?

Should I conclude that it's not really possible to change the horizontal brace commands ?
Or that it's too complicated to do, so it's not worth it ?

Edit : are there any other horizontal brace styles in LaTeX, to add comments to an equation ?
User avatar
Cham
 
Posts: 411
Joined: Sat Apr 2nd, 2011

Re: Thinner Braces in Math Mode

Postby hugovdberg on Sun Nov 18th, 2012

I think the only other option would be drawing them using TikZ or the like, then you have full control over how your braces look like. But designing them might be a tedious task.
Ubuntu 13.10 + Tex Live 2013 + Texmaker / Windows 7 Pro + MikTex 2.9 + TexnicCenter / Android 4.3 + TexPortal + DroidEdit
hugovdberg
 
Posts: 133
Joined: Sat Feb 25th, 2012
Location: 's-Hertogenbosch, Netherlands

Re: Thinner Braces in Math Mode

Postby cgnieder on Sun Nov 18th, 2012

mathtools says about \underbrace and \overbrace:

The standard implementation of the math operators \underbrace and \overbrace in LaTeX has some deficiencies. For example, all lengths used internally are fixed and optimized for 10 pt typesetting. As a direct consequence thereof, using font sizes other than 10 will produce less than optimal results. Another unfortunate feature is the size of the braces. In the example below, notice how the math operator \sum places its limit compared to \underbrace.


The package also tries to fix that. So maybe using mathtools will give already what you want. Note the »mathtools« internally also loads »amsmath«.

Regards
Clemens
------------------------------
New German Q&A site about TeX: http://texwelt.de/wissen
System: TeXlive 2013, OpenSUSE 12.3
User avatar
cgnieder
Site Moderator
 
Posts: 1696
Joined: Sat Apr 16th, 2011
Location: Germany

Re: Thinner Braces in Math Mode

Postby Cham on Sun Nov 18th, 2012

I'm already using the mathtools package.

Is there any other way to add comments under (or above) an equation term ?
User avatar
Cham
 
Posts: 411
Joined: Sat Apr 2nd, 2011

Re: Thinner Braces in Math Mode

Postby cgnieder on Sun Nov 18th, 2012

Here is a TikZ solution (that might have some rough edges...) I basically stole from here:

Code: Select all  •  Open in writeLaTeX
\documentclass[12pt,letterpaper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}

\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing
}
\makeatletter
\def\underbrace#1{%
  \@ifnextchar_{\tikz@@underbrace{#1}}{\tikz@@underbrace{#1}_{}}}
\def\tikz@@underbrace#1_#2{%
  \tikz[baseline=(a.base)] {\node[inner sep=0] (a) {\(#1\)};
  \draw[line cap=round,decorate,decoration={brace,amplitude=5pt}]
    (a.south east) -- node[below,inner sep=7pt] {\(\scriptstyle #2\)} (a.south west);}
}
\def\overbrace#1{%
  \@ifnextchar^{\tikz@@overbrace{#1}}{\tikz@@overbrace{#1}^{}}}
\def\tikz@@overbrace#1^#2{%
  \tikz[baseline=(a.base)] {\node[inner sep=0] (a) {\(#1\)};
  \draw[line cap=round,decorate,decoration={brace,amplitude=5pt}]
    (a.north west) -- node[pos=.5,above,inner sep=7pt] {\(\scriptstyle #2\)} (a.north east);}}
\makeatother

\begin{document}
Test with braces:
\begin{equation}
 \underbrace{ABCD}_{\text{this is a test}} + DEFG = \overbrace{HIJK}^{\text{this is a test}}
\end{equation}

\end{document
}


Regards
Clemens
------------------------------
New German Q&A site about TeX: http://texwelt.de/wissen
System: TeXlive 2013, OpenSUSE 12.3
User avatar
cgnieder
Site Moderator
 
Posts: 1696
Joined: Sat Apr 16th, 2011
Location: Germany

Next

Return to Math & Science

Who is online

Users browsing this forum: No registered users and 5 guests