在数组中格式化长方程

在数组中格式化长方程

在此处输入图片描述我有一个 3 X 1 数组,它太长了。我使用 multline 命令来写入它,但它不容易阅读。请问,有没有更好的方法来写这个方程式?

感谢您的帮助。

代码已更新,以显示预期的 3 X 1 矩阵在此处输入图片描述

\begin{multline}
\left[
  \begin{matrix}[2]
 - \frac{K_i ^2}{m^2} \bigg( \frac{\partial z }{\partial x}  \tan(mm^2 e + mm^2 y) + z \cot(m^2 e + m^2 y) . m^2  \frac{\partial y}{\partial x}    \bigg) \times z (\cot(m^2 b(x) + m^2 y)  + \bigg( \frac{K_i}{m} z \cot(m^2 e + m^2 y) . m^2  \frac{\partial b(t)} {\partial x} \bigg)   \bigg( \frac{\partial y}{\partial x} z \frac{K_i}{m}  (\cot(m^2 b(x) + m^2 y) \bigg)\\
 %%
  - \frac{K_i}{m \tau} \left( \cot(m^2 e + m^2 y) . m^2  \frac{\partial y}{\partial x}  \right) \left(  \frac{K_i}{m} z (\cot(m^2 b(x) + m^2 y) \right) + \frac{K_i}{m \tau} \left( \cot(m^2 b(t) + m^2 y) . m^2  \frac{\partial b(t)}{\partial x}  \right) \left(  \frac{\partial y}{\partial x} z \frac{K_i}{m}  \cot(m^2 b(x) + m^2 y) \right) \\
  %%%
   \frac{K_i}{m} \bigg( \frac{\partial^2 y}{\partial^2 x} z \tan(m^2 e + m^2 y)  + \frac{\partial y}{\partial x}  \tan(m^2 e + m^2 y) \frac{\partial z}{\partial x} + \frac{\partial y}{\partial x} z  \cot(m^2(e + y)) m^2 \frac{\partial y}{\partial x} \bigg) \times   \frac{K_i}{m} z \cot(m^2 b(x) + m^2 y) - \frac{\partial y}{\partial x} z \frac{K_i}{m}  \cot(m^2 e + m^2 y) . m^2  \frac{\partial b(t)}{\partial x} \times \frac{\partial y}{\partial x} z \frac{K_i}{m}  \cot(m^2 b(x) + m^2 y)
 \end{matrix}
 \right]
 \\
 -
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \left[
  \begin{matrix}[2]
 -\frac{K_i ^2}{m^2} \bigg( \frac{\partial z }{\partial x}  \cot(m^2 e + m^2 y) - z \tan(m^2 e + m^2 y) . m^2  \frac{\partial y}{\partial x}    \bigg) \times z (\tan(m^2 b(x) + m^2 y)  +  \bigg( \frac{K_i}{m} z \tan(m^2 e + m^2 y) . m^2  \frac{\partial b(t)} {\partial x} \bigg)   \bigg( \frac{\partial y}{\partial x} z \frac{K_i}{m}  (\tan(m^2 b(x) + m^2 y) \bigg)\\
 %%
  \frac{K_i}{m \tau} \left( \tan(m^2 e + m^2 y) . m^2  \frac{\partial y}{\partial x}  \right) \left(  \frac{K_i}{m} z (\tan(m^2 b(x) + m^2 y) \right)- \frac{K_i}{m \tau} \left( \tan(m^2 b(t) + m^2 y) . m^2  \frac{\partial b(t)}{\partial x}  \right) \left(  \frac{\partial y}{\partial x} z \frac{K_i}{m}  \tan(m^2 b(x) + m^2 y) \right) \\
  %%%
   \frac{K_i}{m} \bigg( \frac{\partial^2 y}{\partial^2 x} z \cot(m^2 e + m^2 y)  + \frac{\partial y}{\partial x}  \cot(m^2 e + m^2 y) \frac{\partial z}{\partial x} - \frac{\partial y}{\partial x} z  \tan(m^2(e + y)) m^2 \frac{\partial y}{\partial x} \bigg) \times   \frac{K_i}{m} z \tan(m^2 b(x) + m^2 y)  - \frac{\partial y}{\partial x} z \frac{K_i}{m}  \tan(m^2 e + m^2 y) . m^2  \frac{\partial b(t)}{\partial x} \times \frac{\partial y}{\partial x} z \frac{K_i}{m}  \tan(m^2 b(x) + m^2 y)
 \end{matrix}
 \right]
\end{multline}

我已经包含了我的序言代码。

\usepackage[left=30mm,top=20mm,right=30mm,bottom=20mm]{geometry}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{commath,amsmath}
\usepackage{siunitx}
\usepackage{hyperref}
\usepackage{cite}
\usepackage{float}
\usepackage{booktabs}
\setcounter{secnumdepth}{5} 
\setlength{\parindent}{0em}
\setlength{\parskip}{1em}
\usepackage{amsfonts}
\usepackage{xparse,mathtools}
\def\mtrm#1{\rule{#1}{1.5ex}}
\usepackage{bm}
%\usepackage{derivative}
%\usepackage{epstopdf}
%\renewcommand\thechapter{\Roman{chapter}}

\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{amssymb}
\usepackage{upgreek}
\usepackage{physics}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\DeclarePairedDelimiterX{\rvect}[1]{[}{]}{\,\makervect{#1}\,}

\ExplSyntaxOn
\NewDocumentCommand{\makervect}{m}
 {
  \seq_set_split:Nnn \l_tmpa_seq { , } { #1 }
  \begin{matrix}
  \seq_use:Nn \l_tmpa_seq { & }
  \end{matrix}
 }
\ExplSyntaxOff

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\makeatletter
\renewcommand*\env@matrix[1][\arraystretch]{%
  \edef\arraystretch{#1}%
  \hskip -\arraycolsep
  \let\@ifnextchar\new@ifnextchar
  \array{*\c@MaxMatrixCols c}}
\makeatother

答案1

感谢您发表一些额外的解释。

我有三个主要建议:

  • 我认为,为了排版matrix包含 3x1 向量的环境,您需要在前 2 个元素中各提供 1 个换行符,并在第 3 个向量中提供 2 个换行符。
  • 我将从 切换\left[ \begin{matrix} ... \end{matrix} \right]\begin{bmatrix*}[l] ... \end{bmatrix*}。然后,我将提供一些视觉标志,以指示哪个多行元素是哪个\qquad在连续行的开头插入指令。
  • 我认为这\bigg对于手头的方程来说太大了;我会改用\Bigl\Bigr。我还会分别用和替换所有和的\left实例。\right\Bigl\Bigr

补充三条评论:

  • 我很清楚如何理解.向量中出现的(“点”,又称“句号”)字符。如果它们应该表示乘法,我要么完全省略它们,要么像@Bernard 在他的回答, 用。。。.来代替\cdot

  • 不要使用该commath软件包。正如 David Carlisle 非常宽容地说:“[commath] 软件包是基于对 tex 数学模式的误解”。该软件包 15 年来没有更新的事实也应该让您停下来思考。

  • 除非您知道自己在做什么,否则不要使用该physics软件包——在这种情况下,您可能一开始就不需要该软件包。例如,您真的想忍受该软件包令人讨厌的默认设置,即自动增加涉及 和 的“外部”括号对(和其他成对的分隔符)的大小吗\tan\cot现在,这个设置可以通过使用选项加载包来停用notrig。不过,说实话:有多少包用户physics知道这个选项的存在——或者,就此而言,有多少用户知道关于自动调整涉及三角项的“外部”括号、方括号等的默认设置?

在此处输入图片描述


单独的评论:我不清楚为什么您选择将整个 3x1 向量表示为两个 3x1 向量的差,因为这两个向量仍然需要进一步换行才能使其适合文本块。只显示一个 3x1 向量不是更容易吗,其中前两个元素各占四行,最后一个元素占六行?也许是这样的(请注意使用显示样式的数学,而不是前面屏幕截图中使用的文本样式的数学):

在此处输入图片描述


\documentclass{article}
    
\usepackage[hmargin=30mm,vmargin=20mm]{geometry}
\usepackage{graphicx}
\usepackage{subcaption}
    
%% math-y stuff:
%\usepackage{commath} % do yourself a favor and don't use commath
%\usepackage{amsmath} % amsmath is loaded automatically by mathtools
\usepackage{amssymb}
\usepackage{upgreek}
%%\usepackage{physics} % don't use 'physics' unless you know what you're doing
                        % (in which case you probably won't need it anyway...)
%\usepackage{amsfonts} % amsfonts is loaded automatically loaded by amssymb
\usepackage{mathtools} % for 'bmatrix*' env.; loads 'amsmath' automatically
\usepackage{bm}
%\usepackage{derivative}
    
\usepackage{siunitx}
    
\usepackage{cite}
%%\usepackage{float} % please try to make do without '[H]' position specifier
\usepackage{booktabs}
    
\setcounter{secnumdepth}{5} 
\setlength{\parindent}{0em}
\setlength{\parskip}{1em}
    
\usepackage{xparse}
\def\mtrm#1{\rule{#1}{1.5ex}}
%\usepackage{epstopdf} % no need, since you load 'graphicx'
%\renewcommand\thechapter{\Roman{chapter}}
    
\usepackage[dvipsnames]{xcolor}
    
\usepackage{tikz}
\usetikzlibrary{positioning}
    
\usepackage{hyperref} % it's a good idea to load this package last
    
    
\begin{document}
    
\begin{multline}
\begin{bmatrix*}[l]
       - \frac{K_i ^2}{m^2} 
       \Bigl( \frac{\partial z }{\partial x}  \tan(mm^2 e + mm^2 y) 
       + z \cot(m^2 e + m^2 y) . m^2  \frac{\partial y}{\partial x} \Bigr) 
       \times z (\cot(m^2 b(x) + m^2 y)  \\ % there seems to be a surplus '(' char. on this line
       \qquad{}+ 
       \Bigl( \frac{K_i}{m} z \cot(m^2 e + m^2 y) . m^2  \frac{\partial b(t)} {\partial x} \Bigr)   
       \Bigl( \frac{\partial y}{\partial x} z \frac{K_i}{m}  (\cot(m^2 b(x) + m^2 y) \Bigr) \\[2\jot]
      %%
       - \frac{K_i}{m \tau} 
       \Bigl( \cot(m^2 e + m^2 y) . m^2  \frac{\partial y}{\partial x}  \Bigr) 
       \Bigl( \frac{K_i}{m} z (\cot(m^2 b(x) + m^2 y) \Bigr) \\
       \qquad{}+ \frac{K_i}{m \tau} 
       \Bigl( \cot(m^2 b(t) + m^2 y) . m^2  \frac{\partial b(t)}{\partial x}  \Bigr) 
       \Bigl( \frac{\partial y}{\partial x} z \frac{K_i}{m} \cot(m^2 b(x) + m^2 y) \Bigr) \\[2\jot]
      %%
       \frac{K_i}{m} 
       \Bigl[ \frac{\partial^2 y}{\partial^2 x} z \tan(m^2 e + m^2 y)  
       + \frac{\partial y}{\partial x}  \tan(m^2 e + m^2 y) \frac{\partial z}{\partial x} \\
       \qquad{}+ \frac{\partial y}{\partial x} z  \cot(m^2(e + y)) m^2 \frac{\partial y}{\partial x} \Bigr] 
       \times \frac{K_i}{m} z \cot(m^2 b(x) + m^2 y) \\
       \qquad{}- \frac{\partial y}{\partial x} z \frac{K_i}{m}  \cot(m^2 e + m^2 y) . m^2  
       \frac{\partial b(t)}{\partial x} \times \frac{\partial y}{\partial x} z \frac{K_i}{m}  
       \cot(m^2 b(x) + m^2 y)
\end{bmatrix*}
\\[\jot]
- %%%%%%%%%%%%%
\begin{bmatrix*}[l]
      -\frac{K_i ^2}{m^2} 
      \Bigl( \frac{\partial z }{\partial x}  \cot(m^2 e + m^2 y) 
      - z \tan(m^2 e + m^2 y) . m^2  \frac{\partial y}{\partial x}    \Bigr) 
      \times z (\tan(m^2 b(x) + m^2 y)  \\ % there seems to be a surplus '(' char. on this line too
      \qquad{}+ 
      \Bigl( \frac{K_i}{m} z \tan(m^2 e + m^2 y) . m^2  \frac{\partial b(t)} {\partial x} \Bigr)   
      \Bigl( \frac{\partial y}{\partial x} z \frac{K_i}{m}  (\tan(m^2 b(x) + m^2 y) \Bigr) \\[2\jot]
      %%
      \frac{K_i}{m \tau} 
      \Bigl( \tan(m^2 e + m^2 y) . m^2  \frac{\partial y}{\partial x}  \Bigr) 
      \Bigl(  \frac{K_i}{m} z (\tan(m^2 b(x) + m^2 y) \Bigr) \\
      \qquad{}- \frac{K_i}{m \tau} 
      \Bigl( \tan(m^2 b(t) + m^2 y) . m^2  \frac{\partial b(t)}{\partial x}  \Bigr) 
      \Bigl(  \frac{\partial y}{\partial x} z \frac{K_i}{m}  \tan(m^2 b(x) + m^2 y) \Bigr) \\[2\jot]
      %%
       \frac{K_i}{m} 
       \Bigl[ \frac{\partial^2 y}{\partial^2 x} z \cot(m^2 e + m^2 y)  
       + \frac{\partial y}{\partial x}  \cot(m^2 e + m^2 y) \frac{\partial z}{\partial x} \\
       \qquad{}- \frac{\partial y}{\partial x} z  \tan(m^2(e + y)) m^2 \frac{\partial y}{\partial x} \Bigr] 
       \times   \frac{K_i}{m} z \tan(m^2 b(x) + m^2 y)  \\
       \qquad{}- \frac{\partial y}{\partial x} z \frac{K_i}{m}  \tan(m^2 e + m^2 y) . m^2  
       \frac{\partial b(t)}{\partial x} \times \frac{\partial y}{\partial x} z \frac{K_i}{m}  
       \tan(m^2 b(x) + m^2 y)
\end{bmatrix*}
\end{multline}
    

%%% alternative version
\bigskip
Put $u=\begin{pmatrix} u_1 & u_2 & u_3 \end{pmatrix}'$, where
\begin{align*}
    u_1 &= 
       \frac{K_i ^2}{m^2} \biggl[
       \begin{aligned}[t]
       &- \Bigl( \frac{\partial z }{\partial x}  \tan(mm^2 e + mm^2 y) 
       + z \cot(m^2 e + m^2 y) . m^2  \frac{\partial y}{\partial x} \Bigr) 
       \times z (\cot(m^2 b(x) + m^2 y)  \\ % is there a surplus '(' char. on this line?
       &+ \Bigl( z \cot(m^2 e + m^2 y) . m^2  \frac{\partial b(t)} {\partial x} \Bigr)   
       \Bigl( \frac{\partial y}{\partial x} z  (\cot(m^2 b(x) + m^2 y) \Bigr) \\
       &+ \Bigl( \frac{\partial z }{\partial x}  \cot(m^2 e + m^2 y) 
      - z \tan(m^2 e + m^2 y) . m^2  \frac{\partial y}{\partial x}    \Bigr) 
      \times z (\tan(m^2 b(x) + m^2 y)  \\ % is there a surplus '(' char. on this line?
       &- \Bigl( z \tan(m^2 e + m^2 y) . m^2  \frac{\partial b(t)} {\partial x} \Bigr)   
      \Bigl( \frac{\partial y}{\partial x} z  (\tan(m^2 b(x) + m^2 y) \Bigr) 
      \biggr]
      \end{aligned} \\[2\jot]
    u_2 &= \frac{K_i}{m \tau} \biggl[ {}\cdots{} \biggr] \\[2\jot]
    u_3 &= \frac{K_i}{m} \biggl[ {}\cdots{} \biggr]
\end{align*}
\end{document} 

答案2

cellspace这是一种使用和包获得更易读矩阵和更简单代码的方法mathtools,使用系统化\dfrac。此外,esdiff包简化了偏导数的输入并确保结果符合 \displaystyle。

\documentclass{article}
\usepackage{mathtools}
\usepackage{esdiff} 
\usepackage[math]{cellspace} 
\setlength{\cellspacetoplimit}{2ex}
\setlength{\cellspacebottomlimit}{2ex}

\begin{document}

\[   \begin{bmatrix*}[r]
 - \dfrac{K_i ^2}{m^2} \biggl( \diffp{z}{x} \tan(mm^2 e + mm^2 y) + z \cot(m^2 e + m^2 y) . m^2 \diffp{y}{x} \biggr) \\ {}\times z (\cot(m^2 b(x) + m^2 y) +\cdots \\
\biggl( \dfrac{K_i}{m} z \cot(m^2 e + m^2 y) \cdot m^2 \diffp{b(t)}{x} \biggr) \biggl( \diffp{y}{x} z \dfrac{K_i}{m} (\cot(m^2 b(x) + m^2 y) \biggr)\\
 %%
  - \dfrac{K_i}{m \tau} \left( \cot(m^2 e + m^2 y) \cdot m^2 \diffp{y}{x} \right) \left( \dfrac{K_i}{m} z (\cot(m^2 b(x) + m^2 y) \right)\cdots \\ + \dfrac{K_i}{m \tau} \left( \cot(m^2 b(t) + m^2 y) . m^2 \diffp{b(t)}{x} \right) \left( \diffp{y}{x} z \dfrac{K_i}{m} \cot(m^2 b(x) + m^2 y) \right) \\
  %%%x} z \tan(m^2 e + m^2 y) + \diffp{y}{x} \tan(m^2 e + m^2 y) \diffp{z}{x} \cdots \\ + \diffp{y}{x} z \cot(m^2(e + y)) m^2 \diffp{y}{x} \biggr) \times \dfrac{K_i}{m} z \cot(m^2 b(x) + m^2 y) \c
   \dfrac{K_i}{m} \biggl( \diffp[2]{y}{dots \\ - \diffp{y}{x} z \dfrac{K_i}{m} \cot(m^2 e + m^2 y) . m^2 \diffp{b(t)}{x} \times \diffp{y}{x} z \dfrac{K_i}{m} \cot(m^2 b(x) + m^2 y)
 \end{bmatrix*} \]


 \end{document}

在此处输入图片描述

相关内容