使用 alignat 中的数组创建方程式图例

使用 alignat 中的数组创建方程式图例

我想在方程下方的两列中描述方程中使用的参数。像这样

**** = *******
*** = **********

  -                               -
 |   A: something                |  D: something
-|   B: something               -|  E: something
 |   C: smething                 |  F: something
  -                               -

使用array内部alignat,产生以下输出

\begin{figure} \label{eq1}
\tiny
\begin{alignat}{2}
   & E_{\mathrm{access}}    \mathord{=} E_{\mathrm{read}} \mathord{+} E_{\mathrm{write}} = E_{\mathrm{R\_L1}} \mathord{+} E_{\mathrm{R\_lower}} \mathord{+} E_{\mathrm{W\_L1}} \mathord{+} E_{\mathrm{W\_lower}} \label{equation1} \\
   .... \\
\begin{array}{l l}
   &h_{r1},h_{w1}: &  \text{Read,Write hits in L1}  \\ 
   &h_{r2},h_{w2}: &  \text{Read,Write hits in local L2} \\
   &h_{r3},h_{w3}: &  \text{Read,Write hits in peer L2} \\
   &h_{r4},h_{w4}: &  \text{Read,Write hits in memory} \\
   &E_{1}:         &  \text{Energy per access at L1} \\
   &E_{2}:         &  \text{Energy per access at L2 slice} \\
   &E_{d}:         &  \text{Energy per access at directory} \\
   &E_{r}:         &  \text{Energy per access at router} \\
   &E_{m}:         &  \text{Energy per access at memory} \\
   &E_{N}:         &  \text{Number of hops} \\
   &E_{i}(\mathrm{T}):         &  \text{Energy of tag array} \\
   &E_{i}(\mathrm{T,D}):         &  \text{Aggregate energy of tag and data arrays} \\
\end{array}   
\end{alignat}   
\end{figure}

在此处输入图片描述

奇怪的是,方程式被推到了右边,那是因为我\\在最后一个方程式中使用了它。方程式很长,所以我没有粘贴它们。

此外,如何创建两列图例?

答案1

从对齐部分移除array并将其设置为常规数学元素。由于您位于 中figure,因此默认情况下它应该居中,使其看起来像数学显示:

在此处输入图片描述

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{figure}
  \centering
  \begin{align}
     f(x) &= ax^2 + bx + c
  \end{align}

  $\begin{array}{l l}
     h_{r1},h_{w1}:       & \text{Read,Write hits in L1}  \\ 
     h_{r2},h_{w2}:       & \text{Read,Write hits in local L2} \\
     h_{r3},h_{w3}:       & \text{Read,Write hits in peer L2} \\
     h_{r4},h_{w4}:       & \text{Read,Write hits in memory} \\
     E_{1}:               & \text{Energy per access at L1} \\
     E_{2}:               & \text{Energy per access at L2 slice} \\
     E_{d}:               & \text{Energy per access at directory} \\
     E_{r}:               & \text{Energy per access at router} \\
     E_{m}:               & \text{Energy per access at memory} \\
     E_{N}:               & \text{Number of hops} \\
     E_{i}(\mathrm{T}):   & \text{Energy of tag array} \\
     E_{i}(\mathrm{T,D}): & \text{Aggregate energy of tag and data arrays} \\
  \end{array}$
\end{figure}
\end{document}

您也可以考虑使用array列规范l @{\ :\ } l来自动设置:。预期输出将是

在此处输入图片描述


由于您的列较细,因此您无法将其拆分array为多个并排的列。但是,您可以按照以下方法独立于对齐构造进行拆分:

%...
  $\begin{array}{l @{\ :\ } l}
     h_{r1},h_{w1}       & \text{Read,Write hits in L1}  \\ 
     h_{r2},h_{w2}       & \text{Read,Write hits in local L2} \\
     h_{r3},h_{w3}       & \text{Read,Write hits in peer L2} \\
     h_{r4},h_{w4}       & \text{Read,Write hits in memory} \\
     E_{1}               & \text{Energy per access at L1} \\
     E_{2}               & \text{Energy per access at L2 slice}
  \end{array}\quad
  \begin{array}{l @{\ :\ } l}
     E_{d}               & \text{Energy per access at directory} \\
     E_{r}               & \text{Energy per access at router} \\
     E_{m}               & \text{Energy per access at memory} \\
     E_{N}               & \text{Number of hops} \\
     E_{i}(\mathrm{T})   & \text{Energy of tag array} \\
     E_{i}(\mathrm{T,D}) & \text{Aggregate energy of tag and data arrays}
  \end{array}$
%...

\quad确保 s 的左右部分之间有间隙array。以下是太宽的输出:

在此处输入图片描述

相关内容