我希望根據它們的(子)部分對我的方程式進行編號,因此當我引用它們時,它會顯示例如(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)
PS:這是我的第一個問題,所以我很高興收到進一步改進我的「提問風格」的評論
答案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
選項:只有少數不常用的軟體包需要它。