
常に 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
を文書の序文に追加します。最初のコマンドは、段落を「セクション」、「段落」のように番号付けして調整します。2 番目のコマンドは、段落に従来のセクション単位の番号付け条件を使用して番号を付けることを可能にします。
\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
。
2 つのコマンドの組み合わせが必要であることに注意してください。1 つは、
\counterwithout*{paragraph}{subsubsection}
新しいサブサブセクション (またはサブサブセクションよりも大きい任意の区分) を開始するときに段落番号をリセットしないように LaTeX に指示し、もう 1 つは、
\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}