我想填充以下长度在进入普查前(或者可能在进入document
环境之前)让我不用担心初始化是否已经被调用。
\newlength\EWD
\newlength\HWD
\newlength\HHWD
初始化程序如下,
\def\Init{%
\settowidth{\EWD}{${}={}$}%
\setlength{\HWD}{0.5\dimexpr\linewidth-\EWD\relax}%
\setlength{\HHWD}{0.5\HWD}}
以下是我的真实情况。
\documentclass[twocolumn]{article}
\usepackage[a4paper,margin=1cm]{geometry}
\usepackage{mathtools}
\newlength\EWD
\newlength\HWD
\newlength\HHWD
\def\Init{%
\settowidth{\EWD}{${}={}$}%
\setlength{\HWD}{0.5\dimexpr\linewidth-\EWD\relax}%
\setlength{\HHWD}{0.5\HWD}}
\def\TopLHS#1{\mathrlap{#1}\rule{\HWD}{0pt}}
\def\MiddleLHS#1{\rule{\HHWD}{0pt}\mathclap{#1}\rule{\HHWD}{0pt}}
\def\BottomLHS#1{\rule{\HWD}{0pt}\mathllap{#1}}
\begin{document}
\begin{enumerate}
\item\Init
$\!
\begin{aligned}[t]
\TopLHS{\framebox[3cm]{Top LHS}}\\
\MiddleLHS{\framebox[3cm]{Middle LHS}}\\
\BottomLHS{\framebox[3cm]{Bottom LHS}}
&= \begin{multlined}[t][\HWD]
\framebox[3cm]{Top RHS 1}\\
\framebox[3cm]{Middle RHS 1}\\
\framebox[3cm]{Bottom RHS 1}
\end{multlined}\\
&= \begin{multlined}[t][\HWD]
\framebox[3cm]{Top RHS 2}\\
\framebox[3cm]{Middle RHS 2}\\
\framebox[3cm]{Bottom RHS 2}
\end{multlined}
\end{aligned}
$
\end{enumerate}
\end{document}
欢迎任何建议!
答案1
\Init
这只是将添加作为首要任务的问题\item
;其他地方不能保证参数得到正确评估
\documentclass[twocolumn]{article}
\usepackage[a4paper,margin=1cm]{geometry}
\usepackage{mathtools}
\AtBeginDocument{%
\expandafter\def\expandafter\item\expandafter{%
\expandafter\Init\item}%
}
\newlength\EWD
\newlength\HWD
\newlength\HHWD
\def\Init{%
\settowidth{\EWD}{${}={}$}%
\setlength{\HWD}{0.5\dimexpr\linewidth-\EWD\relax}%
\setlength{\HHWD}{0.5\HWD}}
\def\TopLHS#1{\mathrlap{#1}\rule{\HWD}{0pt}}
\def\MiddleLHS#1{\rule{\HHWD}{0pt}\mathclap{#1}\rule{\HHWD}{0pt}}
\def\BottomLHS#1{\rule{\HWD}{0pt}\mathllap{#1}}
\def\showInit{\texttt{EWD=\the\EWD; HWD=\the\HWD; HHWD=\the\HHWD}}
\begin{document}
\begin{enumerate}
\item
$\!
\begin{aligned}[t]
\TopLHS{\framebox[3cm]{Top LHS}}\\
\MiddleLHS{\framebox[3cm]{Middle LHS}}\\
\BottomLHS{\framebox[3cm]{Bottom LHS}}
&= \begin{multlined}[t][\HWD]
\framebox[3cm]{Top RHS 1}\\
\framebox[3cm]{Middle RHS 1}\\
\framebox[3cm]{Bottom RHS 1}
\end{multlined}\\
&= \begin{multlined}[t][\HWD]
\framebox[3cm]{Top RHS 2}\\
\framebox[3cm]{Middle RHS 2}\\
\framebox[3cm]{Bottom RHS 2}
\end{multlined}
\end{aligned}
$
\item\showInit
\begin{itemize}
\item\showInit
\end{itemize}
\end{enumerate}
\end{document}
宏\showItem
只是为了展示参数的值,其内部itemize
应该是不同的。