![子方程式在对齐环境中自定义阿拉伯数字](https://linux22.com/image/293968/%E5%AD%90%E6%96%B9%E7%A8%8B%E5%BC%8F%E5%9C%A8%E5%AF%B9%E9%BD%90%E7%8E%AF%E5%A2%83%E4%B8%AD%E8%87%AA%E5%AE%9A%E4%B9%89%E9%98%BF%E6%8B%89%E4%BC%AF%E6%95%B0%E5%AD%97.png)
我有一个对专家来说相当简单的问题!:)
使用子方程,它会自动按字母顺序列举子方程。
有没有办法获得阿拉伯数字枚举?比如
等式:...(1)
等式:...(2)
等式: ... (3.1)
等式: ... (3.2)
等式:...(4)
... 等等
这是我的 MWE:
\documentclass[10pt,twoside]{article}
\usepackage{chadstyle} % Loads my formatting
\usepackage{url}
\usepackage{hyperref}
\usepackage{amssymb}
\usepackage{amsthm, etoolbox}
\usepackage[title,titletoc]{appendix}
\usepackage{pdflscape}
\usepackage{mathtools}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{placeins} % rotating Tables
\usepackage{rotating} % coloring table columns and rows
\usepackage{colortbl}
\newcolumntype{a}{>{\columncolor[gray]{.8}}c}
\newcolumntype{b}{>{\columncolor{white}}c}
\patchcmd{\subequations}{\def\theequation{\theparentequation\alph{equation}}}%
{\def\theequation{\theparentequation.\arabic{equation}}}{}{}
%some shortcut commands ....
\begin{document}
\section{Model}
\begin{subequations}
\begin{align} Y_m &= X P_m^{-\sigma_x} \label{eq:Demand_Yg} \\
Y_s &= X P_s^{-\sigma_x} \label{eq:Demand_Ys}
\end{align}
\end{subequations}
\end{document}
是否可以将补丁嵌入到这个 chadstyle 包中?如您所见,我已经将其放在开头了。谢谢!
% chadstyle.sty Chad Jones, 5/1/08
%
% Chad's style file for nice paper format.
% Various ideas for this style are taken from
% -- Matthias Doepke and Michele Tertilt
% -- Tony Roberts
\special{papersize=8.5in,11in}
%\usepackage{palatino,amssymb,amsfonts,amsmath,latexsym,setspace}
\usepackage{utopia,amssymb,amsfonts,latexsym,setspace}
\usepackage{amsthm, etoolbox}
\patchcmd\subequations
{\theparentequation\alph{equation}}
{\subequationsformat}
{}{}
\newcommand{\subequationsformat}{\theparentequation.\arabic{equation}}
\usepackage[dvips]{graphicx}
\usepackage{fancyhdr}
\usepackage[longnamesfirst]{natbib}
% example file to change the style of LaTeX
% Tony Roberts May 2004
% first colour for latex or pdflatex
\ifx\pdfoutput\@undefined\usepackage[usenames,dvips]{color}
\else\usepackage[usenames,dvipsnames]{color}
% and fix pdf colour problems
\IfFileExists{pdfcolmk.sty}{\usepackage{pdfcolmk}}{}
\fi
% Chad's colors:
% See http://web.njit.edu/~kevin/rgb.txt.html for possibilities
\definecolor{ChadDarkBlue}{rgb}{.1,0,.2}
\definecolor{ChadBlue}{rgb}{.1,.1,.5}
\definecolor{ChadRoyal}{rgb}{.2,.2,.8}
%\definecolor{ChadGreen}{rgb}{0,.35,.1}
%\definecolor{ChadGreen}{rgb}{0,.5,.25} % Too bright
%\definecolor{ChadGreen}{rgb}{0,.4,.2} % Still too bright
\definecolor{ChadGreen}{rgb}{0,.4,0} % Dark Green
%\definecolor{ChadRed}{rgb}{.8,.1,.2} % Too bright
\definecolor{ChadRed}{rgb}{.5,0,.5} % purple
%%% HYPERLINKS %%%%%%%%%%%%%%%%%%%%%
\usepackage[colorlinks,breaklinks,
bookmarks=false,
pdfstartview=Fit, % for fitting entire page; FitW just fits width
pdfview=Fit, % after traversing a hyperlink
linkcolor=ChadRed,
urlcolor=ChadGreen,
citecolor=Black,
hyperfootnotes=false
]{hyperref}
\usepackage[figure,table]{hypcap} % Correct a problem with hyperref
\urlstyle{rm} %so it doesn't use a typewriter font for url's.
%%%%%%%%%%%%%%%%%%%%%
% Fix title, sections, etc.
\let\LaTeXtitle\title
\renewcommand{\title}[1]{\LaTeXtitle{\color{ChadBlue}{\LARGE #1}}}
\renewcommand{\abstractname}{\color{ChadBlue}Abstract}
\renewcommand{\figurename}{\color{ChadBlue}Figure}
\renewcommand{\tablename}{\color{ChadBlue}Table}
\let\LaTeX@startsection\@startsection
\renewcommand{\@startsection}[6]{\LaTeX@startsection%
{#1}{#2}{#3}{#4}{#5}{\color{ChadBlue}\raggedright #6}}
% Fix periods at end of section numbers
%\renewcommand \thesection {\@arabic\c@section.}
%\renewcommand\thesubsection {\thesection\@arabic\c@subsection.}
%\renewcommand\thesubsubsection{\thesubsection \@arabic\c@subsubsection.}
% Margin, Paragraph Setup
\onehalfspacing
\textheight=23cm \textwidth=17cm \topmargin=-8.5mm
%default: \textheight=22cm \textwidth=16cm \topmargin=-6.5mm
\oddsidemargin=3mm \evensidemargin=3mm
%\setlength{\parindent}{0em}
%\setlength{\parskip}{1.5ex plus0.5ex minus0.5ex}
%\setlength{\parsep}{0pt}
\setlength{\parskip}{0pt}
% This is how to control linespacing using setspace
% (\singlespacing or doublespacing just call this command)
\setstretch{1.4}
%% Setting up page headers
\pagestyle{fancy}
\rhead[]{\thepage}
\lhead[\thepage]{}
\cfoot[]{}
\renewcommand{\headrulewidth}{0pt}
\newcommand{\runningheads}[2]{
\chead[\color{ChadGreen}{\uppercase {\footnotesize #1}}] % Author page header
{\color{ChadGreen}{\uppercase {\footnotesize #2}}} % Short title
}
% Make hyperlinks jump more accurately
\makeatletter
\newcommand\org@hypertarget{}
\let\org@hypertarget\hypertarget
\renewcommand\hypertarget[2]{%
\Hy@raisedlink{\org@hypertarget{#1}{}}#2%
} \makeatother
% Spacing in Tables and Figures
%\renewcommand{\tabcolsep}{1pt} % space between columns
\renewcommand{\arraystretch}{1.5} % space between rows
\addtolength{\textfloatsep}{0pt} % space between floats and text
\addtolength{\abovecaptionskip}{0pt} % space above caption
\addtolength{\belowcaptionskip}{.15in} % space below caption
\newcommand{\spc}[0]{\vspace{.1in}}
\newcommand{\fignote}[2]{\begin{center}\parbox[c]{#1}{\footnotesize #2} \end{center}}
\newcommand{\tabnote}[2]{\begin{center}\parbox[c]{#1}{\footnotesize #2} \end{center}}
大家好,我找到了使用 chadstyle 包解决问题的方法。我只是在子方程环境中包含了命令:
\documentclass[10pt,twoside]{article}
\usepackage{amsthm, etoolbox}
.
.
.
\begin{document}
.
.
.
\begin{subequations}
\newcommand{\subequationsformat}{\theparentequation.\arabic{equation}}
\begin{align}
a = b \\
c = d
\end{align}
\end{subequations}
.
.
.
\end{document}
感谢您抽出时间和提出所有建议!祝好,E
答案1
该amsmath
包没有提供用于更改方程式数字外观的接口subequations
,但我们可以使用以下方式添加一个etoolbox
:
\documentclass{article}
\usepackage{amsmath,etoolbox}
\patchcmd\subequations
{\theparentequation\alph{equation}}
{\subequationsformat}
{}{}
\newcommand{\subequationsformat}{\theparentequation.\arabic{equation}}
\begin{document}
Some text
\begin{equation}
1=1
\end{equation}
some text
\begin{subequations}
\begin{gather}
2=2\\
3=3
\end{gather}
\end{subequations}
some text
\begin{equation}
0=0
\end{equation}
\end{document}
基本上,我删除了默认设置,将控制权交给用户可定义的宏。修改\subequationsformat
以适合您的喜好。
hyperref
由于补丁必须完成,因此它稍微复杂一些前加载中hyperref
。
\documentclass[10pt,twoside]{article}
%\usepackage{chadstyle} % Loads my formatting
\usepackage{url}
\usepackage{amssymb}
\usepackage{amsthm, etoolbox}
\usepackage[title,titletoc]{appendix}
\usepackage{pdflscape}
\usepackage{mathtools}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{placeins} % rotating Tables
\usepackage{rotating} % coloring table columns and rows
\usepackage{colortbl}
\patchcmd\subequations
{\theparentequation\alph{equation}}
{\subequationsformat}
{}{}
\usepackage{hyperref}
\newcolumntype{a}{>{\columncolor[gray]{.8}}c}
\newcolumntype{b}{>{\columncolor{white}}c}
\newcommand{\subequationsformat}{\theparentequation.\arabic{equation}}
%some shortcut commands ....
\begin{document}
\section{Model}
\begin{subequations}
\begin{align} Y_m &= X P_m^{-\sigma_x} \label{eq:Demand_Yg}\\
Y_s &= X P_s^{-\sigma_x} \label{eq:Demand_Ys}
\end{align}
\end{subequations}
\ref{eq:Demand_Yg}
\end{document}
您的任何软件包都不应在 之后加载hyperref
。请检查 中的软件包chadstyle
(我不知道里面有什么)。
答案2
环境subequations
已将格式硬编码到其中,因此更改起来并不容易。最简单的解决方案是修补定义:
\documentclass{article}
\usepackage{amsmath}
\usepackage{etoolbox}
\patchcmd{\subequations}{\def\theequation{\theparentequation\alph{equation}}}%
{\def\theequation{\theparentequation.\arabic{equation}}}{}{}
\begin{document}
\begin{equation}
a = b
\end{equation}
\begin{subequations}
\begin{align}
c &=d \\
e &=f
\end{align}
\end{subequations}
\begin{align}
g &= h\\
i &= j
\end{align}
\end{document}