我正在输入一份包含许多大型矩阵的技术报告。我正在寻找一种方法来打印这些矩阵并在其旁边显示方程编号,而不会出现 \hbox 过满错误。
我在想是否可以暂时改变矩阵的页边距。我真的不想使用较小的文本,因为这样矩阵就会变得有点难以阅读。这是我的矩阵目前的样子。任何建议都将不胜感激。谢谢。
我创建上述矩阵的代码如下:
\documentclass[12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
\setcounter{MaxMatrixCols}{20}
\begin{document}
\begin{equation}
\textbf{k}
=
\begin{bmatrix}
\frac{EA}{L} & 0 & 0 & 0 & 0 & 0 & \frac{-EA}{L} & 0 & 0 & 0 & 0 & 0 \\
& \frac{12EI_z}{L^3} & 0& 0& 0& \frac{6EI_z}{L^2} & 0& \frac{-12EI_z}{L^3} & 0 & 0& 0 &\frac{6EI_z}{L^2} \\
& & \frac{12EI_y}{L^3} & 0& \frac{-6EI_y}{L^2} & 0& 0& 0& \frac{-12EI_y}{L^3} & 0& \frac{-6EI_y}{L^2} & 0 \\
& & & \frac{GI_p}{L} & 0 & 0 & 0 & 0 & 0 & \frac{-GI_p}{L} & 0 & 0 \\
& & & & \frac{4EI_y}{L}& 0 & 0& 0 & \frac{6EI_y}{L^2}& 0 & \frac{2EI_y}{L} & 0 \\
& & & & & \frac{4EI_z}{L} & 0 & \frac{-6EI_z}{L^2}& 0 & 0 & 0 & \frac{2EI_z}{L} \\
& & & & & & \frac{EA}{L} & 0 & 0 & 0 & 0 & 0 \\
& & & & & & & \frac{12EI_z}{L^3} & 0 & 0 & 0 & \frac{-6EI_z}{L^2} \\
& & & & & & & & \frac{12EI_y}{L^3} & 0 & \frac{6EI_y}{L^2} & 0 \\
& & & & & & & & & \frac{GI_p}{L} & 0 & 0 \\
& & & & & & & & & & \frac{4EI_y}{L}& 0 \\
symm. & & & & & & & & & && \frac{4EI_z}{L}
\end{bmatrix}
\label{kmat}
\end{equation}
\end{document}
答案1
我停止了 symm 扩展第一列(不要对多字母单词使用数学斜体)并稍微减少了列填充:
\documentclass[12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
\setcounter{MaxMatrixCols}{20}
\begin{document}
\begin{equation}\setlength\arraycolsep{4pt}
\textbf{k}
=
\begin{bmatrix}
\frac{EA}{L} & 0 & 0 & 0 & 0 & 0 & \frac{-EA}{L} & 0 & 0 & 0 & 0 & 0 \\
& \frac{12EI_z}{L^3} & 0& 0& 0& \frac{6EI_z}{L^2} & 0& \frac{-12EI_z}{L^3} & 0 & 0& 0 &\frac{6EI_z}{L^2} \\
& & \frac{12EI_y}{L^3} & 0& \frac{-6EI_y}{L^2} & 0& 0& 0& \frac{-12EI_y}{L^3} & 0& \frac{-6EI_y}{L^2} & 0 \\
& & & \frac{GI_p}{L} & 0 & 0 & 0 & 0 & 0 & \frac{-GI_p}{L} & 0 & 0 \\
& & & & \frac{4EI_y}{L}& 0 & 0& 0 & \frac{6EI_y}{L^2}& 0 & \frac{2EI_y}{L} & 0 \\
& & & & & \frac{4EI_z}{L} & 0 & \frac{-6EI_z}{L^2}& 0 & 0 & 0 & \frac{2EI_z}{L} \\
& & & & & & \frac{EA}{L} & 0 & 0 & 0 & 0 & 0 \\
& & & & & & & \frac{12EI_z}{L^3} & 0 & 0 & 0 & \frac{-6EI_z}{L^2} \\
& & & & & & & & \frac{12EI_y}{L^3} & 0 & \frac{6EI_y}{L^2} & 0 \\
& & & & & & & & & \frac{GI_p}{L} & 0 & 0 \\
& & & & & & & & & & \frac{4EI_y}{L}& 0 \\
\rlap{\textit{symm.}} & & & & & & & & & && \frac{4EI_z}{L}
\end{bmatrix}
\label{kmat}
\end{equation}
\end{document}
答案2
TABstack 可以做到这一点,而不会出现框过满的情况。列间间隙和行间基线跳跃分别设置为
\setstacktabbedgap{1ex}
\setstackgap{L}{1.4\baselineskip}
编辑\rlap
“symm.”,既不让它影响列大小,又将其作为文本。
因此,MWE 为:
\documentclass[12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath,tabstackengine}
\setcounter{MaxMatrixCols}{20}
\begin{document}
\begin{equation}
\setstacktabbedgap{1ex}
\setstackgap{L}{1.4\baselineskip}
\textbf{k}
=
\bracketMatrixstack{
\frac{EA}{L} & 0 & 0 & 0 & 0 & 0 & \frac{-EA}{L} & 0 & 0 & 0 & 0 & 0 \\
& \frac{12EI_z}{L^3} & 0& 0& 0& \frac{6EI_z}{L^2} & 0& \frac{-12EI_z}{L^3} & 0 & 0& 0 &\frac{6EI_z}{L^2} \\
& & \frac{12EI_y}{L^3} & 0& \frac{-6EI_y}{L^2} & 0& 0& 0& \frac{-12EI_y}{L^3} & 0& \frac{-6EI_y}{L^2} & 0 \\
& & & \frac{GI_p}{L} & 0 & 0 & 0 & 0 & 0 & \frac{-GI_p}{L} & 0 & 0 \\
& & & & \frac{4EI_y}{L}& 0 & 0& 0 & \frac{6EI_y}{L^2}& 0 & \frac{2EI_y}{L} & 0 \\
& & & & & \frac{4EI_z}{L} & 0 & \frac{-6EI_z}{L^2}& 0 & 0 & 0 & \frac{2EI_z}{L} \\
& & & & & & \frac{EA}{L} & 0 & 0 & 0 & 0 & 0 \\
& & & & & & & \frac{12EI_z}{L^3} & 0 & 0 & 0 & \frac{-6EI_z}{L^2} \\
& & & & & & & & \frac{12EI_y}{L^3} & 0 & \frac{6EI_y}{L^2} & 0 \\
& & & & & & & & & \frac{GI_p}{L} & 0 & 0 \\
& & & & & & & & & & \frac{4EI_y}{L}& 0 \\
\rlap{symm.} & & & & & & & & & && \frac{4EI_z}{L}
}
\label{kmat}
\end{equation}
\end{document}
答案3
如果您确实需要大量空间……
\documentclass[12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
\usepackage{pdflscape}
\setcounter{MaxMatrixCols}{20}
\begin{document}
\begin{landscape}
\noindent\rule{\linewidth}{1pt}
\begin{equation}\arraycolsep=1em
\textbf{k}
=
\begin{bmatrix}
\frac{EA}{L} & 0 & 0 & 0 & 0 & 0 & \frac{-EA}{L} & 0 & 0 & 0 & 0 & 0 \\
& \frac{12EI_z}{L^3} & 0& 0& 0& \frac{6EI_z}{L^2} & 0& \frac{-12EI_z}{L^3} & 0 & 0& 0 &\frac{6EI_z}{L^2} \\
& & \frac{12EI_y}{L^3} & 0& \frac{-6EI_y}{L^2} & 0& 0& 0& \frac{-12EI_y}{L^3} & 0& \frac{-6EI_y}{L^2} & 0 \\
& & & \frac{GI_p}{L} & 0 & 0 & 0 & 0 & 0 & \frac{-GI_p}{L} & 0 & 0 \\
& & & & \frac{4EI_y}{L}& 0 & 0& 0 & \frac{6EI_y}{L^2}& 0 & \frac{2EI_y}{L} & 0 \\
& & & & & \frac{4EI_z}{L} & 0 & \frac{-6EI_z}{L^2}& 0 & 0 & 0 & \frac{2EI_z}{L} \\
& & & & & & \frac{EA}{L} & 0 & 0 & 0 & 0 & 0 \\
& & & & & & & \frac{12EI_z}{L^3} & 0 & 0 & 0 & \frac{-6EI_z}{L^2} \\
& & & & & & & & \frac{12EI_y}{L^3} & 0 & \frac{6EI_y}{L^2} & 0 \\
& & & & & & & & & \frac{GI_p}{L} & 0 & 0 \\
& & & & & & & & & & \frac{4EI_y}{L}& 0 \\
symm. & & & & & & & & & && \frac{4EI_z}{L}
\end{bmatrix}
\label{kmat}
\end{equation}
\end{landscape}
\end{document}
您可以使用 minipage 和负 \hspace 暂时更改边距,但这是错误的。
\documentclass[12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
\setcounter{MaxMatrixCols}{20}
\begin{document}
\noindent\rule{\textwidth}{1pt}
\medskip
\noindent\hspace{-.25in}\begin{minipage}{\dimexpr \textwidth+.5in}
\noindent\rule{\textwidth}{1pt}
\begin{equation}
\textbf{k}
=
\begin{bmatrix}
\frac{EA}{L} & 0 & 0 & 0 & 0 & 0 & \frac{-EA}{L} & 0 & 0 & 0 & 0 & 0 \\
& \frac{12EI_z}{L^3} & 0& 0& 0& \frac{6EI_z}{L^2} & 0& \frac{-12EI_z}{L^3} & 0 & 0& 0 &\frac{6EI_z}{L^2} \\
& & \frac{12EI_y}{L^3} & 0& \frac{-6EI_y}{L^2} & 0& 0& 0& \frac{-12EI_y}{L^3} & 0& \frac{-6EI_y}{L^2} & 0 \\
& & & \frac{GI_p}{L} & 0 & 0 & 0 & 0 & 0 & \frac{-GI_p}{L} & 0 & 0 \\
& & & & \frac{4EI_y}{L}& 0 & 0& 0 & \frac{6EI_y}{L^2}& 0 & \frac{2EI_y}{L} & 0 \\
& & & & & \frac{4EI_z}{L} & 0 & \frac{-6EI_z}{L^2}& 0 & 0 & 0 & \frac{2EI_z}{L} \\
& & & & & & \frac{EA}{L} & 0 & 0 & 0 & 0 & 0 \\
& & & & & & & \frac{12EI_z}{L^3} & 0 & 0 & 0 & \frac{-6EI_z}{L^2} \\
& & & & & & & & \frac{12EI_y}{L^3} & 0 & \frac{6EI_y}{L^2} & 0 \\
& & & & & & & & & \frac{GI_p}{L} & 0 & 0 \\
& & & & & & & & & & \frac{4EI_y}{L}& 0 \\
symm. & & & & & & & & & && \frac{4EI_z}{L}
\end{bmatrix}
\label{kmat}
\end{equation}
\end{minipage}\hspace{-.25in}
\end{document}