**为清晰起见进行了编辑:**
我正在处理一个较大的文档,主要用 Word 编写,但有一章使用 Rmarkdown/LaTex。我想使用 LaTex 功能转换以下 LaTex 代码,使用此 LaTex 图像:
\documentclass{article}
\usepackage[utf8]{inputenc}
\title{Sections and Numbering}
\author{Paul Hargarten}
\date{June 2020}
\usepackage{natbib}
\usepackage{graphicx}
\begin{document}
\maketitle
\section{Introduction}
This is the first section.
Lorem ipsum dolor sit amet, consectetuer adipiscing
elit. Etiam lobortisfacilisis sem. Nullam nec mi et
neque pharetra sollicitudin. Praesent imperdietmi nec ante.
Donec ullamcorper, felis non sodales...
\begin{figure}[h!]
\centering
\includegraphics[scale=0.5]{LaTex.png}
\caption{LaTex Text Editor}
\label{fig:LaTex}
\end{figure}
\section{Second Section}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Etiam lobortis facilisissem. Nullam nec mi et neque pharetra
sollicitudin. Praesent imperdiet mi necante...(Figure \ref{fig:LaTex}).
\end{document}
我想手动添加“第 3 章”以及相应的章节和图表标题。没有总标题;该文档可以视为书中的一章。我通过 手动调整了标题\title{Chapter 3: Sections and Chapters}
。我想手动添加“3。”或告诉 LaTex 将“3。”添加到章节标题和图表中,这样输出将显示“3.1 简介、3.2 第 2 节等”,如下所示。
Chapter 3: Sections and Chapters
3.1 Introduction
This is the first section.
3.2 Second Section
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Etiam lobortis facilisissem. Nullam nec mi et neque pharetra
sollicitudin. Praesent imperdiet mi necante... (Figure 3.1).
Figure 3.1: LaTex Text Editor.
谢谢。
答案1
您可以简单地重新定义等的输出\thesection
:\thefigure
\documentclass{article}
\usepackage[utf8]{inputenc}
\title{Sections and Numbering}
\author{Paul Hargarten}
\date{June 2020}
\renewcommand{\thesection}{3.\arabic{section}}
\renewcommand{\thefigure}{3.\arabic{figure}}
\renewcommand{\thetable}{3.\arabic{table}}
\usepackage{natbib}
\usepackage[demo]{graphicx}
\begin{document}
\maketitle
\section{Introduction}
This is the first section.
Lorem ipsum dolor sit amet, consectetuer adipiscing
elit. Etiam lobortisfacilisis sem. Nullam nec mi et
neque pharetra sollicitudin. Praesent imperdietmi nec ante.
Donec ullamcorper, felis non sodales...
\begin{figure}[h!]
\centering
\includegraphics[scale=0.5]{LaTex.png}
\caption{LaTex Text Editor}
\label{fig:LaTex}
\end{figure}
\section{Second Section}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Etiam lobortis facilisissem. Nullam nec mi et neque pharetra
sollicitudin. Praesent imperdiet mi necante...(Figure \ref{fig:LaTex}).
\end{document}