\section* 和 \numberwithin 之间是否存在不兼容性?

\section* 和 \numberwithin 之间是否存在不兼容性?

我必须\section*{}在论文中使用,因为我需要对齐目录。但是当我使用时,\numberwithin{}{}方程式被编号为 (0.1)、(0.2) 等。\numberwithin{}{}使用时似乎无法识别章节\section*。当我尝试根据章节对命题进行编号时,也会发生同样的情况,即它们变成了命题 0.1,等等。我该如何使用两者?

\documentclass[a4paper,12pt,oneside]{article}

\usepackage[left=3cm,top=3cm,right=2cm,bottom=2cm]{geometry}

\usepackage{amsmath,amsfonts,amssymb,arial,graphicx,longtable,setspace,color,booktabs,ragged2e}

\usepackage{indentfirst}

\usepackage[portuges]{babel}

\pagestyle{myheadings}

\newtheorem{theorem}{Teorema}[section] 

\newtheorem{definition}[theoremm]{Definition}

\newtheorem{example}[theorem]{Example}

\renewcommand{\figurename}{Figura}

\renewcommand{\contentsname}{\centering \normalsize Sum\'ario}

\usepackage[applemac]{inputenc}

\def\changemargin#1#2{\list{}{\rightmargin#2\leftmargin#1}\item[]}

\let\endchangemargin=\endlist

\onehalfspacing

\newtheorem{theorem}{Teorema}
\newtheorem{acknowledgement}[theorem]{Acknowledgement}
\newtheorem{algorithm}[theorem]{Algorithm}
\newtheorem{axiom}[theorem]{Hip\'{o}tese}
\newtheorem{case}[theorem]{Case}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{conclusion}[theorem]{Conclusion}
\newtheorem{condition}[theorem]{Hip—tese}
\newtheorem{conjecture}[theorem]{Conjecture}
\newtheorem{corollary}[theorem]{Corol\'{a}rio}
\newtheorem{criterion}[theorem]{Criterion}
\newtheorem{definition}[theorem]{Defini\c{c}\~ao}
\newtheorem{example}[theorem]{Exemplo}
\newtheorem{exercise}[theorem]{Exercise}
\newtheorem{lemma}[theorem]{Lema}
\newtheorem{notation}[theorem]{Notation}
\newtheorem{problem}[theorem]{Problem}
\newtheorem{proposition}[theorem]{Proposi\c{c}\~ao}
\newtheorem{remark}[theorem]{Remark}
\newtheorem{solution}[theorem]{Solution}
\newtheorem{summary}[theorem]{Summary}
\newenvironment{proof}[1][Prova]{\noindent\textbf{#1.} }{\ \rule{0.5em}{0.5em}}

\numberwithin{equation}{section}

\begin{document}

\thispagestyle{empty}
\singlespacing
\begin{center}
\textbf{\normalsize UNIVERSIDADE FEDERAL DO RIO GRANDE DO SUL}

\textbf{\normalsize FACULDADE DE CIæNCIAS ECONïMICAS}

\textbf{\normalsize PROGRAMA DE PîS-GRADUA‚ÌO EM ECONOMIA}
\vspace{3cm}

\vspace{3cm}

\large Marcelo de Carvalho Griebeler\\

\vspace{3cm}
\textbf{\large ENSAIOS EM TEORIA ECON\^{O}MICA}\\

\vspace{4cm}

\begin{flushright}
\normalsize
\end{flushright}

\vspace{5cm}

\normalsize \textbf{Porto Alegre}

\normalsize \textbf{2013}
\end{center}

\newpage

\thispagestyle{empty}
\singlespacing
\begin{center}
\textbf{\large Marcelo de Carvalho Griebeler}

\vspace{3cm}

\vspace{3cm}

\textbf{\large ENSAIOS EM TEORIA ECON\^{O}MICA}\\

\vspace{4cm}

\begin{changemargin}{7.4cm}{0.6cm}
Tese submetida ao Programa de P\'{o}s-Gradu\c{c}\~{a}o em Economia da Faculdade de Ci\^{e}ncias Econ\^{o}micas da UFRGS, como quesito parcial para obten\c{c}\~{a}o do t\'{i}tulo de Doutor em Economia, com \^{e}nfase em Economia Aplicada.
\end{changemargin}

\begin{flushright}
\normalsize Orientador: Prof. Dr. Ronald Otto Hillbrecht
\end{flushright}

\vspace{5cm}

\normalsize \textbf{Porto Alegre}

\normalsize \textbf{2013}
\end{center}
\end{document}

答案1

不存在不兼容性。计数器部分从零开始。该命令\section会增加此计数器而不是\section*。因此,您会获得正确的部分编号。

您可以稍后更改编号方案。但是,我认为在文档内部更改编号方案不是一个好的做法。

答案2

您可以定义自己的部分命令,以便在使用 更改部分时手动增加部分计数器\section*。这可能会解决您的问题。此示例同时使用新命令和原始命令\section*来显示差异。

在此处输入图片描述

\documentclass{article}
\usepackage{amsthm}

\newcommand{\mysection}[1]{%
  \stepcounter{section}
  \section*{#1}
}
\newtheorem{theorem}{Teorema}[section] 

\begin{document}

\mysection{First section}
This section starts with \verb!\mysection!. The section counter is
incremented, but does not appear above.
\begin{theorem}\label{thm:first}
First theorem of first section.
\end{theorem}

\section*{Second section}
This section starts with \verb!section*!, so the section counter isn't
incremented. 
\begin{theorem}\label{thm:second}
First theorem of second section.
\end{theorem}

\mysection{Third section}
This section starts with \verb!\mysection!.
\begin{theorem}\label{thm:third}
First theorem of third section.
\end{theorem}

References: Teorema~\ref{thm:first}, Teorema~\ref{thm:second}, 
Teorema~\ref{thm:third}.
\end{document}

相关内容