Same height for matrices regardless of fractions inside [closed]

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:

I cannot use arbitrary packages nor can I redefine anything, because I encountered this inside [itex] on Wikipedia.

• 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
• You could put a \vphantom{\frac\theta2} in the cells not containing a fraction. – Skillmon likes topanswers.xyz Feb 13 at 12:29
• @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
• 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
• @Mico this is about [itex] on Wikipedia, not LaTeX (off topic?). – rbrignall Feb 13 at 13:08

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.

\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}