I am using latex to write my thesis and it has the following numbering structure which is quite confusing when I make reference to previous chapters. For example, if am in chapter 3 and want to reference a subsection in chapter 2, I use section \ref{section 1} and it's not clear which section 1 I want (chapter 1 or 2).
So, how do I change the above like the image below
Below is the code in my header then inside the document I use \chapter, \section and \subsection to distinguish them.
\documentclass[a4paper,11pt]{report}
% Preamble
\usepackage[utf8x]{inputenc}
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}
\usepackage{subfig}
\usepackage{fullpage}
\usepackage{tabularx}
\usepackage{comment}
\usepackage{color, colortbl}
\usepackage{graphicx}
\usepackage{url}
\usepackage{setspace}
\usepackage{float}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{varioref}
\usepackage{multirow}
\usepackage{hhline}
\renewcommand\thesection{\arabic{section}}
\usepackage{parskip}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{caption}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\renewcommand{\arraystretch}{1.3}
\usepackage{lscape}
\usepackage{multirow}
\usepackage{hyperref}
\hypersetup{
colorlinks,
citecolor=black,
filecolor=black,
linkcolor=black,
urlcolor=black
}
\usepackage{longtable}
\setlength{\parindent}{0pt}
[1]: https://i.stack.imgur.com/tsJLC.png
[2]: https://i.stack.imgur.com/xNruu.png
\renewcommand\bibname{References} % change title of references section
\newcommand{\myquote}[2]{\begin{center}\fbox{\begin{minipage}{.95\linewidth}#1\hfill #2\end{minipage}}\end{center}}
\newcommand{\source}[1]{\caption*{{#1}} }
\usepackage{natbib} \input{natbib-add}
\bibliographystyle{named}
\bibpunct{[}{]}{;}{a}{}{}
%\setlength{\skip\footins}{1.5cm}
\setlength{\intextsep}{10pt plus 2pt minus 2pt}
It's this line:
\renewcommand\thesection{\arabic{section}}
It changes the section numbering to start from 1, like the chapters already are. Just delete the line and the sections are numbered 1.1, 1.2, etc.
Related
I'm trying to remove the space in LoF between different chapters. i have tried different solutions(patching it as well) but it is not working. I have attached the codes below for your reference. Any help or pointers to resolve it would be highly appreciated.
Edit: Link to a minimal working project file depicting the error.
Working Example
\documentclass[twoside, 12pt]{report}
\usepackage[utf8]{inputenc}
\usepackage{pdfpages}
%package for higlighting text
\usepackage{color,soul}
%packages for multicol glossary, bibliography and list
\usepackage[section,numberedsection=autolabel, acronym]{glossaries}
\usepackage{setspace}
\usepackage{enumitem}
\usepackage[style=ieee]{biblatex}
\usepackage{glossary-mcols}
\usepackage{multicol}
%package for comments
\usepackage{verbatim}
%%Random text
\usepackage{lipsum}
%packages for fancy headers
\usepackage{blindtext}
\usepackage{fancyhdr}
\usepackage{tikz}
%package for subfigures
\usepackage{subfigure}
\makeglossaries
% Use package below to change margins and graphics
\usepackage{graphicx}
\usepackage[a4paper,top=25mm,bottom=25mm,left=25mm,right=25mm]{geometry}
% text color package
\usepackage{xcolor}
% use to customize chapter headings of toc lof lot
\usepackage{tocloft}
\renewcommand{\cfttoctitlefont}{\hspace*{\fill}\Large\bfseries}
\renewcommand{\cftaftertoctitle}{\hspace*{\fill}}
\renewcommand{\cftlottitlefont}{\hspace*{\fill}\Large\bfseries}
\renewcommand{\cftafterlottitle}{\hspace*{\fill}}
\renewcommand{\cftloftitlefont}{\hspace*{\fill}\Large\bfseries}
\renewcommand{\cftafterloftitle}{\hspace*{\fill}}
\usepackage{sectsty}
\chapternumberfont{\Large}
\chaptertitlefont{\Large}
\usepackage{hyperref}
%for table
\usepackage{booktabs}
%maths Package
\usepackage{amsmath}
%minted package
\usepackage[]{minted}
\usepackage{fancyvrb}
%for greek words
\usepackage[utf8]{inputenc}
\usepackage[greek,english]{babel}
\usepackage{lmodern}
\usemintedstyle{vs}
\setminted{bgcolor=myGray,
breaklines,
mathescape,
linenos,
numbersep=5pt,
frame=single,
numbersep=5pt,
xleftmargin=0pt,
breaksymbolleft=\raisebox{0.8ex}{
\small\reflectbox{\carriagereturn}},
breaksymbolindentleft=0pt,
breaksymbolsepleft=0pt,
breaksymbolindentright=0pt,
breaksymbolsepright=0pt
}
%for code listing
\usepackage{xcolor}
\usepackage{listings}
\definecolor{myGray}{RGB}{245, 239, 239}
\definecolor{maroon}{RGB}{128,0,0}
\definecolor{forestGreen}{RGB}{1,68,33}
\lstdefinestyle{mystyle}{
backgroundcolor=\color{myGray},
commentstyle=\color{forestGreen},
keywordstyle=\color{blue},
numberstyle=\tiny\color{gray},
stringstyle=\color{maroon},
basicstyle=\ttfamily\small,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=left,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=2,
frame=single
}
\lstset{style=mystyle}
%Patch to remove the space in LoF, LoT, LoC per chapter basis
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\makeatletter
\patchcmd{\#chapter}{\addtocontents{lof}{\protect\addvspace{10\p#}}}{}{}{}% LoF
\patchcmd{\#chapter}{\addtocontents{lot}{\protect\addvspace{10\p#}}}{}{}{}% LoT
\makeatother
%for custom caption
\usepackage{caption}
% document begins here
\begin{document}
%Footer and header fancy - chapter x. ChapterName format
\fancyhead{}
\fancyhead[RO,LE]{\leftmark}
\fancyfoot{}
\fancyfoot[CE,CO]{\thepage}
\newpage
\phantomsection
\tableofcontents
\addcontentsline{toc}{chapter}{Table of Contents}
\newpage
\listoftables
\phantomsection
\addcontentsline{toc}{chapter}{\listtablename}
\newpage
\listoffigures
\phantomsection
\addcontentsline{toc}{chapter}{\listfigurename}
\newpage
\renewcommand{\lstlistingname}{Code}
\renewcommand{\lstlistlistingname}{List of \lstlistingname s}
\lstlistoflistings
\phantomsection
\addcontentsline{toc}{chapter}{\lstlistlistingname}
%CHAPTERS BEGIN
\pagenumbering{arabic}
\newpage
\input{Chapters/Intro}
\input{Chapters/Results}
\newpage
%%APPENDIX BEGINS
\fancyhead{}
\fancyfoot{}
\end{document}
Please find below the code for respective
The below figures are part of sample Intro file.
\begin{figure}[h]
\centering
\includegraphics[scale=0.5]{<someImage>}
\caption{Software Development Lifecycle}
\label{fig:swCycle}
\end{figure}
\begin{figure}[h]
\centering
\includegraphics[scale=0.5]{<someImage>}
\caption{Software Development Lifecycle2}
\label{fig:swCycle2}
\end{figure}
Results File
\begin{figure}[h]
\centering
\includegraphics[scale=0.5]{<someImage>}
\caption{Software Development Lifecycle3}
\label{fig:swCycle3}
\end{figure}
You could remove the spaces between the list entries of different chapters if you make the patches before you load hyperref:
\documentclass[twoside, 12pt]{report}
% use to customize chapter headings of toc lof lot
\usepackage{tocloft}
\renewcommand{\cfttoctitlefont}{\hspace*{\fill}\Large\bfseries}
\renewcommand{\cftaftertoctitle}{\hspace*{\fill}}
\renewcommand{\cftlottitlefont}{\hspace*{\fill}\Large\bfseries}
\renewcommand{\cftafterlottitle}{\hspace*{\fill}}
\renewcommand{\cftloftitlefont}{\hspace*{\fill}\Large\bfseries}
\renewcommand{\cftafterloftitle}{\hspace*{\fill}}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\#chapter}{\addtocontents{lof}{\protect\addvspace{10\p#}}}{}{}{}
\patchcmd{\#chapter}{\addtocontents{lot}{\protect\addvspace{10\p#}}}{}{}{}
\makeatother
% load hyperref after these patches
\usepackage{hyperref}
\begin{document}
\listoffigures
\chapter{test}
\begin{figure}[htbp]
\caption{heading}
\end{figure}
\chapter{test}
\begin{figure}[htbp]
\caption{heading}
\end{figure}
\end{document}
While working today, after hours of tweaking and fixing with the latex markup and making things prettier in the work, I all of the suddenly, after a refresh saw this:
All used packages:
\usepackage{caption}
\usepackage{blindtext}
\usepackage{pifont,mdframed}
\usepackage{enumitem}
\usepackage{amssymb}
\usepackage[titles]{tocloft}
\usepackage{hyperref} % Hyperlinks
\usepackage[nameinlink,noabbrev,capitalise]{cleveref} % Better in-doc refs
\usepackage[title,toc,titletoc,page]{appendix}
\usepackage{multirow}
\usepackage[margin=2cm]{geometry}
\usepackage{graphicx}
\usepackage{float} % Better figure and table placements
\usepackage{tabularx}
\usepackage{amsmath} % For using \text in equations
\usepackage{csquotes} % For blockquote
\usepackage[labelfont=it, labelsep=period]{caption}
\usepackage{subcaption}
\usepackage{color}
\usepackage{xcolor,colortbl}
\usepackage[final]{pdfpages} % used to include pdf to appendicies
\usepackage{lipsum}
\usepackage{microtype} % Slightly tweak font spacing for aesthetics
\usepackage{lettrine}
\usepackage{longtable}
\usepackage{ragged2e}
Declaration and usage:
\makeatletter
\newrobustcmd{\fixappendix}{%
\patchcmd{\l#subsection}{2.3em}{5.6em}{}{}%
}
\makeatother
\cleardoublepage
\newpage
\appendix
\addtocontents{toc}{\fixappendix}
\renewcommand{\thesubsection}{\appendixname~\arabic{subsection}}
Was caused by: \usepackage[titles]{tocloft}.
I'm using the following settings on Overleaf:
\documentclass[%
aip,
jmp,%
amsmath,amssymb,
%preprint,%
reprint,%
nofootinbib,
nobibnotes,
%author-year,%
%author-numerical,%
10pt
]{revtex4-2}
\usepackage{graphicx}% Include figure files
\usepackage{dcolumn}% Align table columns on decimal point
\usepackage{bm}% bold math
\usepackage{tabularx}
\usepackage[a4paper, total={6.5in, 9in}]{geometry}
\usepackage{microtype}
\usepackage[english]{babel}
\usepackage[utf8]{inputenx}
\usepackage{bm}
\usepackage{amsbsy}
\usepackage{fixmath}
\usepackage{commath}
\usepackage{float}
\usepackage{siunitx} % notazione \num{e-}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{xcolor}
%\usepackage{subcaption}
\usepackage{hyperref}
\usepackage{curve2e}
%\usepackage{caption}
\usepackage{subcaption}
%\usepackage{silence}
%\WarningFilter{caption}{Unsupported document class}
%\usepackage[center]{subfigure}
\usepackage{comment}
%\usepackage[mathlines]{lineno}% Enable numbering of text and display math
%\linenumbers\relax % Commence numbering lines
and I get the following warning:
Package caption Warning: Unknown document class (or package), standard defaults will be used. See the caption package documentation for explanation.
The thing is that I've commented the caption package (it shouldn't be active anymore), trying to replace it with subcaption.
Is there a way to solve the warning?
subcaption automatically loads the caption package. The warning is vanishes if you remove this package as well:
\documentclass[%
aip,
jmp,%
amsmath,amssymb,
%preprint,%
reprint,%
nofootinbib,
nobibnotes,
%author-year,%
%author-numerical,%
10pt
]{revtex4-2}
\usepackage{graphicx}% Include figure files
\usepackage{dcolumn}% Align table columns on decimal point
\usepackage{bm}% bold math
\usepackage{tabularx}
\usepackage[a4paper, total={6.5in, 9in}]{geometry}
\usepackage{microtype}
\usepackage[english]{babel}
\usepackage[utf8]{inputenx}
\usepackage{bm}
\usepackage{amsbsy}
\usepackage{fixmath}
\usepackage{commath}
\usepackage{float}
\usepackage{siunitx} % notazione \num{e-}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{xcolor}
%\usepackage{subcaption}
\usepackage{hyperref}
\usepackage{curve2e}
%\usepackage{caption}
%\usepackage{subcaption}
%\usepackage{silence}
%\WarningFilter{caption}{Unsupported document class}
%\usepackage[center]{subfigure}
\usepackage{comment}
%\usepackage[mathlines]{lineno}% Enable numbering of text and display math
%\linenumbers\relax % Commence numbering lines
\begin{document}
content...
\end{document}
I got some big latex source that compiles to a booklet that justifies text in an alternating manner, left-right-left-right, so that it's nice for printing I guess. How can you remove that? I can't share the entire thing, but it starts with:
\documentclass[12pt, a4paper, twoside]{book}
\usepackage{helvet}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{textcomp}
\usepackage[
a4paper,
outer=2cm,
inner=4cm,
top=2cm,
bottom=2cm
]{geometry}
\usepackage{float}
\usepackage{tabularx}
\usepackage[disable]{todonotes}
%\usepackage{color, soul}
\usepackage{color}
\usepackage{amsmath}
\usepackage{algorithmicx}
\usepackage[noend]{algpseudocode}
\usepackage{algorithm}
\usepackage{framed}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{titlepic}
\usepackage{fancyhdr}
\usepackage[simplified]{pgf-umlcd}
\usepackage{tikz}
\definecolor{grey}{rgb}{0.9, 0.9, 0.9}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{dkred}{rgb}{0.6,0,0.0}
\lstdefinestyle{DOS}
{
backgroundcolor=\color{black},
basicstyle=\scriptsize\color{white}\ttfamily,
stringstyle=\color{white},
keywords={}
}
\lstdefinestyle{makefile}
{
numberblanklines=false,
language=make,
tabsize=4,
keywordstyle=\color{red},
identifierstyle= %plain identifiers for make
}
Found the answer, and it was because of some code that I didn't include above
\fancyhf{}
\fancyhead[LO, RE]{\small \rightmark}
\fancyfoot[LO, RE]{\small \thepage}```
It was the LO, RE that means Left side when odd page, right side on even pages. So, changed that to LO, LE and it's now consistent
Is it possible to create footers like above in xelatex? on the first page the number to be aligned on the right and on the second page on the left side. The top border would be a nice addition but it is not necessary. I don't need any text (section names) beside the numbers.
\documentclass[11pt,a4paper]{article}
\usepackage{fontspec}
\setmainfont{Charis SIL}
\usepackage{geometry}
\geometry{a4paper, left=1in, right=1in,
top=0.5in, bottom=0.65in}
\setlength{\parindent}{0pt}
\setlength{\parskip}{1em}
\setcounter{secnumdepth}{0}
\usepackage{sectsty}
\sectionfont{\huge}
\subsectionfont{\Large}
\subsubsectionfont{\large}
\paragraphfont{\normalsize}
\usepackage{hyperref}
\subparagraphfont{\normalsize}
\renewcommand{\baselinestretch}{1.5}"
If you are using the twoside documentclass option, then you can use the fancyhdr package to add such a footline:
\documentclass[11pt,a4paper,twoside]{article}
\usepackage{fontspec}
\setmainfont{Charis SIL}
\usepackage{geometry}
\geometry{a4paper, left=1in, right=1in,
top=0.5in, bottom=0.65in}
\setlength{\parindent}{0pt}
\setlength{\parskip}{1em}
\setcounter{secnumdepth}{0}
\usepackage{sectsty}
\sectionfont{\huge}
\subsectionfont{\Large}
\subsubsectionfont{\large}
\paragraphfont{\normalsize}
\usepackage{hyperref}
\subparagraphfont{\normalsize}
\renewcommand{\baselinestretch}{1.5}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{1pt}
\fancyhead{}
\fancyfoot{}
\fancyfoot[LE,RO]{\thepage}
\usepackage{duckuments}
\begin{document}
\duckument
\end{document}