# How to reduce the number “0” size to fit fraction “1/2”?

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
\usepackage{mathtools}
\begin{document}
\renewcommand{\arraystretch}{1.2}
\newcommand{\minus}{\scalebox{0.4}[1.0]{$-$}}
$\begin{bmatrix*}[r] 0& \minus\frac{1}{2} &\frac{1}{2} \\ \minus\frac{1}{2}& 0&\minus\frac{1}{2}\\ \frac{1}{2}& \minus\frac{1}{2}&0 \end{bmatrix*}$
\end{document}


How to reduce the number “0” size to fit fraction "1/2"? (reduce height of "0" ?)

update sample

As below photo shows the proportion close to 1/3

• Welcome to TeX.SE. Please add a full MWE, see tex.meta.stackexchange.com/questions/228/…. – CampanIgnis Sep 19 at 15:21
• As far as I know, it is uncommon to reduce the height of numbers. The package ctan.org/pkg/xfrac might be interesting, though. – CampanIgnis Sep 19 at 15:22
• How much are you wanting to reduce the 0? It's already smaller than the fraction 1/2. Or are you wanting it to be the same size as the 1 or 2? Have you tried \dfrac to increase the size of the fractions? – Teepeemm Sep 19 at 15:32
• @Teepeemm about 1/3 of "1/2" – user67646 Sep 19 at 16:39
• @CampanIgnis Thx, I try fit it to the new upload photo(the rendering engine not LaTeX) – user67646 Sep 19 at 16:43

I would second Mico's recommendation to not do this. But the solution would be to make the fractions display style rather than shrink the zeros (your example was likely set by naïve software which doesn't know how to properly resize fractions. Here's another alternative setting adapted from your MWE:

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
\usepackage{mathtools}
\begin{document}
\newcommand{\half}{{\displaystyle\frac{1}{2}\vphantom{\frac{1}{2}^1_1}}}
$\begin{bmatrix*}[r] 0& -\half &\half \\ -\half& 0&-\half\\ \half& -\half&0 \end{bmatrix*}$
\end{document}


I put the fraction in \displaystyle and used a \vphantom to add extra spacing—perhaps not enough—above and below the fractions.

I wouldn't reduce the size of the 0 numerals. If you believe that they look too big in relation to the text-style \frac{1}{2} expressions, maybe what's really needed is to replace the \frac terms with their decimal representations -- of course while aligning the numbers on their (explicit or implicit decimal markers.

\documentclass{article}
\usepackage{mathtools}  % for 'bmatrix*' env.
\usepackage{siunitx}    % for 'S' column type
\begin{document}
$\renewcommand\arraystretch{1.33} \begin{bmatrix*}[r] 0 & -\frac{1}{2} & \frac{1}{2} \\ -\frac{1}{2} & 0 & -\frac{1}{2} \\ \frac{1}{2} & -\frac{1}{2} & 0 \end{bmatrix*}$

$\left[ % note: no need to increase the value of '\arraystretch' \begin{array}{@{} *{3}{S[table-format=-1.1]} @{}} 0 & -0.5 & 0.5 \\ -0.5 & 0 & -0.5\\ 0.5 & -0.5 & 0 \end{array} \right]$
\end{document}

• Compare to decimal shows i prefer to put the matrix element have same layout as new upload photo. – user67646 Sep 19 at 16:48

A good solution, in my opinion, to reduce the size discrepancy between fractions (in text mode by default) and ordinary numbers is to use the medium-sized fractions from nccmath, which are ca 80 % of \displaystyle:

\documentclass{article}
\usepackage{nccmath, mathtools} % for 'bmatrix*' env.
\usepackage{makecell}

\begin{document}

$\setcellgapes{3pt}\makegapedcells \begin{bmatrix*}[r] \phantom{-}0 & -\mfrac{1}{2} & \mfrac{1}{2} \\ -\mfrac{1}{2} & 0 & -\mfrac{1}{2} \\ \mfrac{1}{2} & -\mfrac{1}{2} & 0 \end{bmatrix*}$%

\end{document}


• There is something wrong with the alignment of the middle column. The 0 is slightly to the right it seems. – Anush Sep 19 at 18:42
• @Anush: You're right. When I measure it, the difference in position is 0.8pt (~ 0.28mm).I don't where it comes from. Maybe the side bearings of the fraction? You can add \mkern 1.5mu after the 0 to compensate. – Bernard Sep 19 at 19:12
• @Bernard It's work! – user67646 Sep 20 at 1:25
• @Anush Thank u for your notice! – user67646 Sep 20 at 1:27

The image which the OP posted looks like display style fractions \dfrac were used. As stated in my comment, shrinking the 0 in these situations is uncommon. Generally speaking, the various Tex engines and most trusted and well used packages have good typographic features by default.

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
\usepackage{mathtools,xfrac}
\begin{document}
\renewcommand{\arraystretch}{1.2}
\newcommand{\minus}{\scalebox{0.4}[1.0]{$-$}}
$\begin{bmatrix*}[r] 0& \minus\frac{1}{2} &\frac{1}{2} \\ \minus\frac{1}{2}& 0&\minus\frac{1}{2}\\ \frac{1}{2}& \minus\frac{1}{2}&0 \end{bmatrix*}$

$\renewcommand{\arraystretch}{2.0}%You will see what happens if you do not use it. It is a local definition which does not affect the third matrix \begin{bmatrix*}[r] 0& -\dfrac{1}{2} &\dfrac{1}{2} \\ -\dfrac{1}{2}& 0&-\dfrac{1}{2}\\ \dfrac{1}{2}& -\dfrac{1}{2}&0 \end{bmatrix*}$

$\begin{bmatrix*}[r] 0& \sfrac{-1}{2} &\sfrac{1}{2} \\ \sfrac{-1}{2}& 0&\sfrac{-1}{2}\\ \sfrac{1}{2}& \sfrac{-1}{2}&0 \end{bmatrix*}$
\end{document}


Top: original; middle: \dfrac; bottom: https://ctan.org/pkg/xfrac.

• Why do you use c for the sfrac bmatrix whilst for the others you use r? – albert Sep 19 at 17:21
• @albert Thank you. I have changed that for consistency. – CampanIgnis Sep 19 at 18:11

I would say that your sample actually suggests the opposite: "I want to preserve regular size even for numerators and denominators". Use \dfrac instead of \frac.

Also, why do you have special treatment for minus? Why the - isn't enough?

\documentclass{article}

\usepackage{amsmath}
\usepackage{array}
\usepackage{mathtools}

\begin{document}
\renewcommand{\arraystretch}{2}
$\begin{bmatrix*}[r] 0 & -\dfrac{1}{2} & \dfrac{1}{2} \\ -\dfrac{1}{2} & 0 & -\dfrac{1}{2} \\ \dfrac{1}{2} & -\dfrac{1}{2} & 0 \end{bmatrix*}$
\end{document}


• I think your middle column has something wrong with its alignment. The 0 seems shifted to the right. Is that an illusion? – Anush Sep 19 at 18:44
• I just used the same alignment as the question author had in the question. And every fraction line has something extra on both sides, that's the root cause. – ivankokan Sep 19 at 23:33