![根据小节对方程式进行编号,但不显示没有编号的小节](https://linux22.com/image/476664/%E6%A0%B9%E6%8D%AE%E5%B0%8F%E8%8A%82%E5%AF%B9%E6%96%B9%E7%A8%8B%E5%BC%8F%E8%BF%9B%E8%A1%8C%E7%BC%96%E5%8F%B7%EF%BC%8C%E4%BD%86%E4%B8%8D%E6%98%BE%E7%A4%BA%E6%B2%A1%E6%9C%89%E7%BC%96%E5%8F%B7%E7%9A%84%E5%B0%8F%E8%8A%82.png)
我希望根据方程式的(子)部分对其进行编号,这样当我引用它们时,它会显示例如(1.1),但是我的部分和小节不应显示其编号,因此部分应看起来像“SECTION”而不是“1 SECTION”,小节应看起来像“SUBSECTION”而不是“1.1 SUBSECTION”,这是我当前的代码,它不显示数字,但没有按希望对方程式进行编号:
\documentclass[pdftex,10pt,a4paper]{article}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]
{geometry}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{dcolumn}
\usepackage[english]{babel}
\usepackage{siunitx}
\usepackage{mhchem}
%Command to not display numbers of sections and subsections...
\makeatletter
\renewcommand\thesection{}
\renewcommand\thesubsection{}
\renewcommand\thesubsubsection{}
\makeatother
% command to number equations according to the their sections
\numberwithin{equation}{section}
\begin{document}
\section{Introduction}
\subsubsection{Theoretical principles}
here comes some text and the first reference \eqref{eq:lnpp0} the text goes on
then the first eqation is implemented.
\begin{equation}\label{eq:lnpp0}
\mathrm{ln} \dfrac{p}{p_0} \, = \, \dfrac{\Delta_\mathrm{v}H}{R}\left( \dfrac{1}{T_0}-\dfrac{1}{T}\right)
\end{equation}
Rearranging the equation the formula gives you $\Delta_\mathrm{v}H$
for the enthalpy of vaporization which can be used to
determine the entropy of vaporization:
\begin{equation}\label{eq:deltaS}
\Delta_\mathrm{v}S\,=\, \dfrac{\Delta_\mathrm{v}H}{T}
\end{equation}
\section{The second section}
This is the equation i want to reference to \eqref{eq:lnpp0}
\end{document}
此代码不显示章节和小节的编号(如所愿),但未正确编号方程式,而是编号为(.1)而不是(1.1)
附言:这是我的第一个问题,所以我很高兴收到评论,以进一步改进我的“提问风格”
答案1
你不应该将thesection
etc 重新定义为空。但可以使用以下方法重新定义部分级别titlesec
\usepackage{titlesec}
\titleformat{\section}
{\normalfont\Large\bfseries}{}{0em}{}
\titleformat{\subsection}
{\normalfont\large\bfseries}{}{0em}{}
\titleformat{\subsubsection}
{\normalfont\normalsize\bfseries}{}{0em}{}
\titleformat{\paragraph}[runin]
{\normalfont\normalsize\bfseries}{}{0em}{}
\titleformat{\subparagraph}[runin]
{\normalfont\normalsize\bfseries}{}{0em}{}
我已经重新定义了所有级别以供您参考,以便没有级别显示数字。
有了这些,我们得到
但这可能会让你的读者感到困惑。
完整代码:
\documentclass[10pt,a4paper]{article}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]
{geometry}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{dcolumn}
\usepackage[english]{babel}
\usepackage{siunitx}
\usepackage{mhchem}
%Command to not display numbers of sections and subsections...
\usepackage{titlesec}
\titleformat{\section}
{\normalfont\Large\bfseries}{}{0em}{}
\titleformat{\subsection}
{\normalfont\large\bfseries}{}{0em}{}
\titleformat{\subsubsection}
{\normalfont\normalsize\bfseries}{}{0em}{}
\titleformat{\paragraph}[runin]
{\normalfont\normalsize\bfseries}{}{0em}{}
\titleformat{\subparagraph}[runin]
{\normalfont\normalsize\bfseries}{}{0em}{}
% command to number equations according to the their sections
\numberwithin{equation}{section}
\begin{document}
\section{Introduction}
\subsubsection{Theoretical principles}
here comes some text and the first reference \eqref{eq:lnpp0} the text goes on
then the first eqation is implemented.
\begin{equation}\label{eq:lnpp0}
\mathrm{ln} \dfrac{p}{p_0} \, = \, \dfrac{\Delta_\mathrm{v}H}{R}\left( \dfrac{1}{T_0}-\dfrac{1}{T}\right)
\end{equation}
Rearranging the equation the formula gives you $\Delta_\mathrm{v}H$
for the enthalpy of vaporization which can be used to
determine the entropy of vaporization:
\begin{equation}\label{eq:deltaS}
\Delta_\mathrm{v}S\,=\, \dfrac{\Delta_\mathrm{v}H}{T}
\end{equation}
\section{The second section}
This is the equation i want to reference to \eqref{eq:lnpp0}
\end{document}
答案2
无需额外的软件包。节号的打印由内部命令执行\@seccntformat
。如果我们将其重新定义为不执行任何操作,则不会出现数字。
\documentclass[10pt,a4paper]{article}
\usepackage{amsmath}
%Command to not display numbers of sections and subsections...
\makeatletter
\renewcommand{\@seccntformat}[1]{}
\makeatother
% command to number equations according to the their sections
\numberwithin{equation}{section}
\begin{document}
\section{Introduction}
\subsubsection{Theoretical principles}
here comes some text and the first reference \eqref{eq:lnpp0} the text goes on
then the first equation is implemented.
\begin{equation}\label{eq:lnpp0}
\ln\frac{p}{p_0} =\frac{\Delta_{\mathrm{v}}H}{R}\left( \frac{1}{T_0}-\frac{1}{T}\right)
\end{equation}
Rearranging the equation the formula gives you $\Delta_\mathrm{v}H$
for the enthalpy of vaporization which can be used to
determine the entropy of vaporization:
\begin{equation}\label{eq:deltaS}
\Delta_{\mathrm{v}}S=\frac{\Delta_{\mathrm{v}}H}{T}
\end{equation}
\section{The second section}
This is the equation I want to reference to \eqref{eq:lnpp0}
\end{document}
我只留下了amsmath
,因为示例不需要其他包(但您当然可以将它们添加到您的文档中)。
需要注意的一些事项。
\mathrm{ln}
是错误而且应该如此\ln
。使用括号括住下标:
\Delta_{\mathrm{v}}
。这个命令
\dfrac
很少需要,\frac
除非你真的需要在需要打印较小版本的地方使用大版本,否则最好使用它。前面不要留空行
equation
。后面可以留空行,但等式后面的文字必须为新段落。永远不要使用该
pdftex
选项:只有少数不常用的包才需要它。