1

**Edited for clarity: **

I am working on a larger document that is primarily written in Word, but I have one chapter that uses Rmarkdown/LaTex. I want to use LaTex features to transform the following LaTex code, using this LaTex image:

this LaTex image

\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}

The code yields this output. output

I want to add "Chapter 3" and the corresponding section and figure headers manually. There's no overall title; the document can be considered a chapter from a book. I adjusted the title manually via \title{Chapter 3: Sections and Chapters} . I would like to manually add "3." or tell LaTex to add "3." to the section headers and figures, so the output would read "3.1 Introduction, 3.2 Section 2, etc." as follows.

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.

Thanks.

2
  • 1
    Welcome to TeX.se, and thanks for adding a minimal document! Is the first output image supposed to be there?
    – Alan Munn
    Jun 27, 2020 at 20:17
  • @AlanMunn You're right, the first output image wasn't supposed to be there. I edited it to be removed.
    – phargart
    Jun 28, 2020 at 21:24

1 Answer 1

2

You can simply redefine the output of \thesection, \thefigure etc:

\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}

output of code

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .