我想要反对段落,总是像 xy 一样,其中 x 是章节编号,y 是该章节中的段落编号。
\documentclass[11pt, twocolumn, a4paper]{article}
\usepackage[left=1.5cm, text={18cm, 25cm}, top=2.5cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[IL2]{fontenc}
\usepackage[czech]{babel}
\usepackage{times}
\begin{document}
\section{A}
foo
\paragraph{Definition % 1.1 %}
here is definition 1.1 and i need to reference it later as 1.1
\section{B}
bar
\paragraph{Definition % 2.1 %}
\end{document}
有人可以帮忙吗?
答案1
以下是一些选项:
你可以通过添加
\paragraph
完全相同的方式进行操作\subsection
\let\paragraph\subsection
添加到文档前言中。或者,直接使用
\subsection
。\documentclass{article} \let\paragraph\subsection% Make \paragraph act just like \subsection \begin{document} \section{A} foo \paragraph{Definition} Here is definition 1.1 and i need to reference it later as 1.1 \section{B} bar \subsection{Definition} \end{document}
\paragraph
通过添加来调整方式\renewcommand{\theparagraph}{\thesection.\arabic{paragraph}}% How paragraphs are numbered \setcounter{secnumdepth}{4}% Number up to paragraphs
到文档序言。第一个命令将段落调整为按“类似部分”的编号。第二个命令实际上允许使用传统的部分单元编号条件对段落进行编号。
\documentclass{article} \renewcommand{\theparagraph}{\thesection.\arabic{paragraph}}% How paragraphs are numbered \setcounter{secnumdepth}{4}% Number up to paragraphs \begin{document} \section{A} foo \paragraph{Definition} Here is definition 1.1 and i need to reference it later as 1.1 \section{B} bar \subsection{C} foo bar \paragraph{Definition} foo bar foo \section{D} foo bar foo bar \subsection{E} bar foo bar foo \subsubsection{F} foo bar foo bar foo \paragraph{Definition} \end{document}
这里的问题是,如果你把
\subsection
s 和\paragraph
s 混在一起,你可能会让读者感到困惑,因为它们的编号相似。此外,它们的编号不会随着每个部分(例如,重新开始)而调整。如果你想让它们重新开始,请咨询连续编号,即按章节/节对图表、表格和其他文档元素进行编号。建议使用\usepackage{chngcntr}% http://ctan.org/pkg/chngcntr \counterwithout{paragraph}{section}
做这个前重新定义
\theparagraph
。
答案2
这是使用该包进行的操作chngcntr
。
请注意,您需要组合两个命令:
\counterwithout*{paragraph}{subsubsection}
告诉 LaTeX,当您开始新的小节(或任何大于小节的部分)时,您不再要重置段落编号;
\counterwithin*{paragraph}{section}
告诉它您想在新的部分(或其上方的任何内容,例如书中的章节)的开头重置段落编号。
\documentclass{article}
\setcounter{secnumdepth}{4}
\renewcommand{\theparagraph}{\arabic{section}.\arabic{paragraph}}
\usepackage{chngcntr}
\counterwithout*{paragraph}{subsubsection} %% stop resetting paragraph number with each new subsubsection
%\counterwithin*{paragraph}{section} %% reset paragraph number for each section; only works with the preceding line!
\begin{document}
\section{Section}
\paragraph{Definition 1}\label{par:1.1}
\subsection{Subsection}
\paragraph{Definition 2}\label{par:1.2}
\subsubsection{Subsubsection}
\paragraph{Definition 3}\label{par:1.3}
\section{Section}
\paragraph{Definition 4}\label{par:2.1}
\subsection{Subsection}
\paragraph{Definition 5}\label{par:2.2}
\subsubsection{Subsubsection}
\paragraph{Definition 6}\label{par:2.3}~
Reference to 1.1: \ref{par:1.1}
Reference to 1.2: \ref{par:1.2}
Reference to 1.3: \ref{par:1.3}
Reference to 2.1: \ref{par:2.1}
Reference to 2.2: \ref{par:2.2}
Reference to 2.3: \ref{par:2.3}
\end{document}