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 am using the unicode-math package to use letters from the body font in math typesetting. The font I am using (Arno Pro) works quite well for this, because it includes a full Greek alphabet on top of the Latin one, but it is not a math font. For characters not included in the font, I am using XITS Math as fallback.

However, some punctuation characters (such as a comma, parenthesis, square brackets and curly brackets) differ significantly between the fonts, so I took those from the body font as well. This works great for the smallest bracket size, but the font does not support the auto-scaling for brackets. Is it possible to instruct unicode-math to use brackets (and parentheses and curly brackets) from one font for the small size, and fall back to an other font for other sizes?

I can switch between fonts like so:

% Use XITS Math for    [     ]     (     )     {     }
\setmathfont[range={"005B,"005D,"0028,"0029,"007B,"007D}]{XITS Math}

% Use Arno Pro for     [     ]     (     )     {     }
\setmathfont[range={"005B,"005D,"0028,"0029,"007B,"007D}]{Arno Pro}

Defining these as new commands makes it slightly easier to handle multiple fonts, but switching does not work in math mode, and even if it did, it would still require manually selecting the correct font for different brackets and parentheses. Does unicode-math offer a way to use one font for the bigger brackets, and an other for the normal size?

An other workaround I found, is to use a proper math font in math mode, for all characters, but set the small brackets using the text font (via \text{\{}). This is a nicer solution, but it still not as nice as I had hoped. Also, this might impact spacing around the bracket.

share|improve this question

1 Answer 1

Attacking the problem from a completely different angle... if your font does not support auto-scaling of brackets etc., are you open to the scalerel package which has a \scaleleftright[]{}{}{} command for mimicking the scale-to-size feature I think you are seeking? In the case of scalerel, it takes the base character and scales it directly to match the height of the target object. But here's the trick: the optional argument is a width limiter, to prevent the scaled object from getting too wide. In this example, I set that argument to 2ex, so that no matter how big the character is scaled, it never gets wider than 2ex.

Alternatively, there is \stretchleftright command which does a vertical stretch, but in that case, it has an aspect-ratio limiter as the optional argument, so that the aspect ratio of the stretched symbol never exceeds the amount given in the optional argument.

In all cases, the auto-scaled object is based on the original font symbol.

\documentclass{article}
\usepackage{scalerel}
\parskip 2ex
\begin{document}
\(
\scaleleftright[2ex]{[}{ x^2}{]}
\scaleleftright[2ex]{(}{ x^2}{)}
\scaleleftright[2ex]{\{}{ x^2}{\}}
\)

\(
\scaleleftright[2ex]{[}{%
\begin{array}{c}%
 x^2\\
y^2\\
\end{array}}{]}
\scaleleftright[2ex]{(}{%
\begin{array}{c}%
 x^2\\
y^2\\
\end{array}}{)}
\scaleleftright[2ex]{\{}{%
\begin{array}{c}%
 x^2\\
y^2\\
\end{array}}{\}}
\)

\(
\scaleleftright[2ex]{[}{%
\begin{array}{c}%
 x^2\\
y^2\\
z^2\\
\end{array}}{]}
\scaleleftright[2ex]{(}{%
\begin{array}{c}%
 x^2\\
y^2\\
z^2\\
\end{array}}{)}
\scaleleftright[2ex]{\{}{%
\begin{array}{c}%
 x^2\\
y^2\\
z^2\\
\end{array}}{\}}
\)

\end{document}

enter image description here

Just for comparison, below I use the \stretchleftright command, rather than the \scaleleftright

enter image description here

share|improve this answer
    
I was unaware of this package. For small bracket sizes (but larger than the normal size), this is indeed a very nice solution. However, for bigger sizes, the brackets look either too thick, or too squashed. I will use this as an additional solution for medium-sized brackets. –  Ruud v A Apr 9 '13 at 17:57
    
@RuudvA admittedly, for some fonts, some symbols, and over some size ranges, it looks better than others. –  Steven B. Segletes Apr 9 '13 at 19:20
    
@RuudvA as shown in my edit, it sometimes pays to explore the subtle differences between \scaleleftright and \stretchleftright. Sometimes, one works better than the other for the application. Also note that the most difficult symbols with which to work (from the viewpoint of thick or squashed) are ones (like [ and ] ) which are composed of purely horizontal and vertical strokes. –  Steven B. Segletes Apr 9 '13 at 19:39

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.