1

How can I force matrices (bmatrix) with the same number of rows to be the same height when only some entries include fractions (\frac)?

I would prefer to increase the size of matrices displayed smaller, rather than decreasing the size of matrices that contain fractions.

R(\theta) = 
\begin{bmatrix}
   1 & -\tan\frac\theta2 \\ 0 & 1
\end{bmatrix}
\begin{bmatrix} % this matrix is displayed smaller than the others
   1 & 0 \\ \sin\theta & 1    % <- no fraction here
\end{bmatrix}
\begin{bmatrix}
   1 & -\tan\frac\theta2 \\ 0 & 1
\end{bmatrix}

Here's how this equation is diplayed on Wikipedia:

enter image description here

I cannot use arbitrary packages nor can I redefine anything, because I encountered this inside <math> on Wikipedia.

  • 3
    You have only provided a code snippet, not an MWE. When I insert the snippet into the simplest possible code, the matrix heights are all the same. Thus, you have not provided enough information to diagnose the issue. – Steven B. Segletes Feb 13 at 12:14
  • 1
    You could put a \vphantom{\frac\theta2} in the cells not containing a fraction. – Skillmon likes topanswers.xyz Feb 13 at 12:29
  • 1
    @Skillmonlikestopanswers.xyz this is about maths on wikipedia. \vphantom doesn't work there. However, this question is arguably off-topic as it is not about LaTeX, but about things that use similar syntax to LaTeX. – rbrignall Feb 13 at 13:06
  • 1
    I am not able to reproduce the issue you claim to have encountered when I compile the samle document. In particular, all three bmatrix environments would appear to be equally tall. – Mico Feb 13 at 13:07
  • 1
    @Mico this is about <math> on Wikipedia, not LaTeX (off topic?). – rbrignall Feb 13 at 13:08
3

I was able to recreate the issue you've experienced on the Wikipedia site by using \dfrac instead of \frac.

I can think of three possible work-arounds.

  • The first solution relies on inserting a typographic strut. This method is feasible only if the \vphantom directive is available.

  • The second method employs \tfrac instead of \frac (or \dfrac). Given that wikipedia's math software "understands" other macros provided by the amsmath package, it may also understand \tfrac.

  • The third employs inline-fraction notation instead of \frac. It should be feasible everywhere, including on Wikipedia sites.

enter image description here

\documentclass{article}
\usepackage{amsmath} % for 'align*' and 'bmatrix' environments
% create a typographic strut:
\newcommand\mystrut{\ensuremath{\vphantom{\dfrac{\theta}{2}}}}

\begin{document}
\begin{align*}
R(\theta) 
&= \begin{bmatrix} % original form
   1 & -\tan\dfrac\theta2 \\ 0 & 1
 \end{bmatrix}
 \begin{bmatrix}
   1 & 0 \\ \sin\theta & 1
 \end{bmatrix}
 \begin{bmatrix}
   1 & -\tan\dfrac\theta2 \\ 0 & 1
 \end{bmatrix} &&\text{Problem recreated with \texttt{\string\dfrac}}\\
&= \begin{bmatrix} % first solution
   1 & -\tan\dfrac\theta2 \\ 0 & 1
 \end{bmatrix}
 \begin{bmatrix}
   1 & 0\mystrut \\ \sin\theta & 1 % <-- note "\mystrut"
 \end{bmatrix}
 \begin{bmatrix}
   1 & -\tan\dfrac\theta2 \\ 0 & 1
 \end{bmatrix} &&\text{Solution 1: Insert a typographic strut} \\
&= \begin{bmatrix} % second solution
   1 & -\tan\tfrac\theta2 \\ 0 & 1
 \end{bmatrix}
 \begin{bmatrix}
   1 & 0 \\ \sin\theta & 1
 \end{bmatrix}
 \begin{bmatrix}
   1 & -\tan\tfrac\theta2 \\ 0 & 1
 \end{bmatrix} &&\text{Solution 2: Use \texttt{\string\tfrac}}\\
&= \begin{bmatrix} % third solution
   1 & -\tan(\theta/2) \\ 0 & 1
 \end{bmatrix}
 \begin{bmatrix}
   1 & 0 \\ \sin\theta & 1 
 \end{bmatrix}
 \begin{bmatrix}
   1 & -\tan(\theta/2) \\ 0 & 1
 \end{bmatrix} &&\text{Solution 3: Use inline-fraction notation}
\end{align*}
\end{document}
|improve this answer|||||

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