101 字

引用最近的一个公式:lasteqn z

LaTeX; LaTeX; 公式;

原文地址:http://bbs.ctex.org/viewthread.php?tid=69755

\documentclass{article}

\usepackage{amsmath}
\providecommand\currentseclabel{}
\newcommand\seclabel[1]{
  \renewcommand\currentseclabel{#1}%
  \label{sec:#1}}
\newcommand\secref[1]{
  \ref{sec:#1}}
\newcommand\eqlabel[1]{
  \label{eq:\currentseclabel:#1}}
\let\saveeqref\eqref
\renewcommand\eqref[2][\currentseclabel]{
  \saveeqref{eq:#1:#2}}
\newcommand\lasteqn{(\theequation)}

\begin{document}
\section{Rectangle}
\seclabel{rect}

\begin{equation}
\eqlabel{area}
A = ab
\end{equation}Area formula \eqref{area}.Previous equation \lasteqn.\section{Circle}
\seclabel{circ}

\begin{equation}
\eqlabel{area}
A = \pi r^2
\end{equation}

Area formula \eqref{area}.\section{Summary}Area of rectangles see \eqref[rect]{area} in section~\secref{rect};
area of circles see \eqref[circ]{area} in section~\secref{circ}.

\end{document}