引用方程式和章节而不列举

引用方程式和章节而不列举

问题是......我想要几件事:

首先,我不想枚举章节(因为我会用它们作为主题)。其次,我想用字母枚举子小节。第三,我想用方程式甚至章节、小节或小小节进行交叉引用。

我拿到了那个代码,

\documentclass[8pt,a4paper,dvipsnames]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage[colorlinks=true]{hyperref}
\hypersetup{linkcolor=black}
\usepackage{cleveref}
\usepackage{chngcntr}
\counterwithin*{equation}{section}
\counterwithin*{equation}{subsection}
\counterwithin*{equation}{subsubsection}

\newcommand{\sect}[1]{
    \section*{#1}
    \addcontentsline{toc}{section}{#1}
    \stepcounter{section}
} %to enumerate sections and put them in toc even they are not enumerated%

\newcommand{\seclabel}[1] {\numberwithin{equation}{section}\label{#1}}
\newcommand{\sseclabel}[1] {\numberwithin{equation}{subsection}\label{#1}}
\renewcommand{\thesubsubsection} {\thesubsection.\alph{subsubsection}} %to enumerate subsubsections with letters%
\newcommand{\ssseclabel}[1] {\numberwithin{equation}{subsubsection}\label{#1}}

\begin{document}
\sect{Test not enumerated}
\begin{equation}
    \pi=3.1416 \seclabel{eq:pi1}
\end{equation}
First, this equation~\eqref{eq:pi1} is properly enumerated but not properly referenced.

\section{Test 2 enumerated}
\begin{equation}
    \pi=3.1416 \seclabel{eq:pi2}
\end{equation}
Equation ~\eqref{eq:pi2} is properly enumerated and referenced.

\sect{Test 3}
\begin{equation}
    \pi=3.1416 \seclabel{eq:pi3}
\end{equation}
This other equation~\eqref{eq:pi3} is properly enumerated and referenced, however the first equation isn't.
\subsection{subsection}
\subsubsection{here inside}
\begin{equation}
    \pi=3.1416 \ssseclabel{eq:pi4}
\end{equation}
Second when I do a cross-reference to equation ~\eqref{eq:pi4} I've not got the letter and right reference either. 
\end{document}

但是我得到了类似这样的信息,实际上枚举是正确的,但引用不正确,非常感谢大家:

您至少知道在哪里可以找到有关如何格式化标签、标号和引用的完整手册吗?

答案1

我不确定,但我想你想要

在此处输入图片描述

\documentclass[a4paper,dvipsnames]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage[colorlinks=true]{hyperref}
\hypersetup{linkcolor=black}
\usepackage{cleveref}
\usepackage{chngcntr}
\counterwithin*{equation}{section}
\counterwithin*{equation}{subsection}
\counterwithin*{equation}{subsubsection}

\newcommand{\sect}[1]{%%%
    \section*{#1}%%%
    \addcontentsline{toc}{section}{#1}%%%
    \refstepcounter{section}%%%
} %to enumerate sections and put them in toc even they are not enumerated%



\renewcommand{\thesubsubsection} {\thesubsection.\alph{subsubsection}} %to enumerate subsubsections with letters%
\renewcommand\theequation{\ifnum\value{subsubsection}>0 \thesubsubsection\else
                          \ifnum\value{subsection}>0 \thesubsection\else
                          \thesection\fi\fi.\arabic{equation}}

\begin{document}
\sect{Test not enumerated}
\begin{equation}
  \pi=3.1416 \label{eq:pi1}
\end{equation}
First, this equation~\eqref{eq:pi1} is properly enumerated but not properly referenced.

\section{Test 2 enumerated}
\begin{equation}
    \pi=3.1416 \label{eq:pi2}
\end{equation}
Equation ~\eqref{eq:pi2} is properly enumerated and referenced.

\sect{Test 3}
\begin{equation}
    \pi=3.1416 \label{eq:pi3}
\end{equation}
This other equation~\eqref{eq:pi3} is properly enumerated and referenced, however the first equation isn't.
\subsection{subsection}
\subsubsection{here inside}
\begin{equation}
    \pi=3.1416 \label{eq:pi4}
\end{equation}
Second when I do a cross-reference to equation ~\eqref{eq:pi4} I've not got the letter and right reference either. 
\end{document}

相关内容