Add tags
Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
by 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}
-

Cham
-
- Posts: 314
- Joined: Sat Apr 2nd, 2011
by 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 (7.82 KiB) Viewed 527 times
Regards
Last edited by cgnieder on Sun Nov 18th, 2012, edited 2 times in total.
Reason: added example + image
-

cgnieder
- Site Moderator
-
- Posts: 1310
- Joined: Sat Apr 16th, 2011
- Location: Germany
-
by 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.
-

Cham
-
- Posts: 314
- Joined: Sat Apr 2nd, 2011
by 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.
-
hugovdberg
-
- Posts: 35
- Joined: Sat Feb 25th, 2012
- Location: 's-Hertogenbosch, Netherlands
by 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
-

cgnieder
- Site Moderator
-
- Posts: 1310
- Joined: Sat Apr 16th, 2011
- Location: Germany
-
by 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 ?
-

Cham
-
- Posts: 314
- Joined: Sat Apr 2nd, 2011
by 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.
-
hugovdberg
-
- Posts: 35
- Joined: Sat Feb 25th, 2012
- Location: 's-Hertogenbosch, Netherlands
by 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
-

cgnieder
- Site Moderator
-
- Posts: 1310
- Joined: Sat Apr 16th, 2011
- Location: Germany
-
by 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 ?
-

Cham
-
- Posts: 314
- Joined: Sat Apr 2nd, 2011
by 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
-

cgnieder
- Site Moderator
-
- Posts: 1310
- Joined: Sat Apr 16th, 2011
- Location: Germany
-
Return to Math & Science
Users browsing this forum: No registered users and 12 guests
|