如何让我的矩阵适合文本块的宽度?

如何让我的矩阵适合文本块的宽度?

我是 LaTeX 的新手。这是我目前所拥有的:

\documentclass[11pt]{article}
\usepackage{amsmath}

\begin{document}

$$ A = \begin{bmatrix}
0 & \cos(\theta_{1})\sin(\phi_{1})\sin(\tau_{1}) & 
\cos(\theta_{2})\sin(\phi_{2})\sin(\tau_{3}) & 
\cos(\theta_{4})\sin(\phi_{4})\sin(\tau_{4}) & 
\cos(\theta_{5})\sin(\phi_{5})\sin(\tau_{5}) & 
\cos(\theta_{6})\sin(\phi_{6})\sin(\tau_{6}) & 
\cos(\theta_{7})\sin(\phi_{7})\sin(\tau_{7}) & 
\cos(\theta_{8})\sin(\phi_{8})\sin(\tau_{8}) & 
\cos(\theta_{8})\sin(\phi_{8})\sin(\tau_{8}) & 
\cos(\theta_{9})\sin(\phi_{9})\sin(\tau_{9}) \\

0  & \sin(\theta_{1})\sin(\phi_{1})\sin(\tau_{1}) & 
\sin(\theta_{2})\sin(\phi_{2})\sin(\tau_{2}) & 
\sin(\theta_{3})\sin(\phi_{3})\sin(\tau_{3}) & 
\sin(\theta_{4})\sin(\phi_{4})\sin(\tau_{4}) & 
\sin(\theta_{5})\sin(\phi_{5})\sin(\tau_{5}) & 
\sin(\theta_{6})\sin(\phi_{6})\sin(\tau_{6})
& \sin(\theta_{7})\sin(\phi_{7})\sin(\tau_{7}) & 
\sin(\theta_{8})\sin(\phi_{8})\sin(\tau_{8}) & 
\sin(\theta_{9})\sin(\phi_{9})\sin(\tau_{9}) \\

0 & \cos(\phi_{1})\sin(\tau_{1}) & \cos(\phi_{2})\sin(\tau_{2}) & 
\cos(\phi_{3})\sin(\tau_{3}) & \cos(\phi_{4})\sin(\tau_{4}) & 
\cos(\phi_{5})\sin(\tau_{5}) & \cos(\phi_{6})\sin(\tau_{6}) & 
\cos(\phi_{7})\sin(\tau_{7}) & \cos(\phi_{8})\sin(\tau_{8}) & 
\cos(\phi_{9})\sin(\tau_{9}) \\

1 & \sin(\tau_{1}) & \sin(\tau_{2}) & \sin(\tau_{3}) & \sin(\tau_{4}) & 
\sin(\tau_{5}) & \sin(\tau_{6}) & \sin(\tau_{7}) & \sin(\tau_{8}) & 
\sin(\tau_{9}) \\
\end{bmatrix}
$$
\end{document}

但是,这不适合文本块的宽度。我该如何解决这个问题?有没有办法调整字体大小或矩阵的整体大小?

答案1

我建议如下:

在此处输入图片描述

\documentclass[11pt]{article}
\usepackage{amsmath}

\begin{document}For $i=1,\dots,9$ write
\begin{align*}
a_i&=\cos(\theta_{i})\sin(\phi_{i})\sin(\tau_{i}),\\ b_i&=\sin(\theta_{i})\sin(\phi_{i})\sin(\tau_{i}),\\ c_i&=\cos(\phi_{i})\sin(\tau_{i})\\
d_i&=\sin(\tau_{i}).
\end{align*} 
Then,
\[A = \begin{bmatrix}
0 &a_1& \cdots & a_9 \\
0 &b_1& \cdots & b_9 \\
0 &c_1& \cdots & c_9 \\
1 &d_1& \cdots & d_9 \\
\end{bmatrix}\]

Alternatively, 
\[A = \begin{bmatrix}
0 &\cos(\theta_{1})\sin(\phi_{1})\sin(\tau_{1})& \cdots & \cos(\theta_{9})\sin(\phi_{9})\sin(\tau_{9}) \\
0 &\sin(\theta_{1})\sin(\phi_{1})\sin(\tau_{1})& \cdots & \sin(\theta_{9})\sin(\phi_{9})\sin(\tau_{9}) \\
0 &\cos(\phi_{1})\sin(\tau_{1})& \cdots & \cos(\phi_{9})\sin(\tau_{9}) \\
1 &\sin(\tau_{1})& \cdots & \sin(\tau_{9}) \\
\end{bmatrix}.\]
\end{document}

答案2

我建议您显示其转置,即 10x4 矩阵,而不是尝试显示 10 列中的 8 列中有宽条目的 4x10 矩阵。

此外,由于转置矩阵第 2 行到第 10 行的单元格仅在行索引上有所不同,因此我建议您在循环中对它们进行排版。如果您可以自由使用 LuaLaTeX,这可以以简单的方式完成。Lua 函数接受 1 个参数,即要打印的行数。因此,如果您决定从 9 行切换到 19 行,您需要做的就是使用调用更改参数fancy_rows

在此处输入图片描述

\theta注意,我省略了、\phi和项周围的所有 9*9=81 对括号\tau。(如果你必须使用括号,将它们插入到 Luafor循环中非常容易。

%%% Must be compiled under LuaLaTeX
\documentclass[11pt]{article}
\usepackage{amsmath} % for 'bmatrix' environment
\usepackage{luacode} % for 'luacode' environment
\begin{luacode}
function fancy_rows ( N )  
  for i=1,N do
    tex.sprint ( "\\cos\\theta_{" ..i.. "}\\sin\\phi_{" ..i.. "}\\sin\\tau_{" ..i.. "}&" )
    tex.sprint ( "\\cos\\theta_{" ..i.. "}\\sin\\phi_{" ..i.. "}\\sin\\tau_{" ..i.. "}&" )
    tex.sprint ( "\\cos\\phi_{"   ..i.. "}\\sin\\tau_{" ..i.. "}&" )
    tex.sprint ( "\\sin\\tau_{"   ..i.. "}" )
    if i<N then tex.sprint ( "\\\\" ) end
  end   
end
\end{luacode}

\begin{document}
\[
A' = \begin{bmatrix}
0 & 0 & 0 & 1 \\
\directlua { fancy_rows(9) }
\end{bmatrix}
\]
\end{document}

相关内容