Latex - \addsec and headsepline - latex

When I write \addsec{Acronymes}, LaTeX puts it in the Table of Contents and DOES the headsepline section. When I write \addsec*{Acronymes}, LaTeX doesnt put it in the Table of Contents and doesnt write it in the headsepline section. But I want that it doesnt appears in the Table of Contents and does appear in the headsepline.
So how do it?
Thats what I've done for this:
\documentclass[a4paper, 12pt, german, headsepline, footsepline, listtotoc, bibtotoc] {scrartcl}
\bibliographystyle{annotate}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[ansinew]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[babel, german=quotes]{csquotes}
\usepackage[printonlyused]{acronym}
%head and footsepline
\usepackage[headsepline,plainheadsepline]{scrpage2}
\clearscrheadfoot
\pagestyle{scrheadings}
\automark[subsection]{section}
\ihead{my title}
\ohead{\headmark}
\ifoot{my name}
\ofoot{\pagemark}
\usepackage{hyperref}
\hypersetup{
colorlinks,
citecolor=blue,
filecolor=blue,
linkcolor=blue,
urlcolor=blue
}
\begin{document}
\input{include/Abstract}
\newpage
\tableofcontents
\newpage
\listoffigures
\newpage
\listoftables
\newpage
\addsec*{Acronymes}
%\addsec{Acronymes}
\begin{acronym}
\acro{HTTP}{Hypertext Transfer Protocol}
\end{acronym}
\end{document}

You can momentarily remove the functionality of \addcontentsline - the macro in charge of adding elements to the ToC - using
{% \begingroup
\renewcommand{\addcontentsline}[3]{}% Remove functionality of \addcontentsline
\addsec{Acronymes}%
}% \endgroup
Grouping via { and } ensure that the command redefinitions are restored after the group ends.

Related

A lot of space at the beginning of the page in Latex

There is a lot of space in the beginning which I do no like. And also to other sections (but only the start page of the section). Do you guys have any clue on how to reduce the vertical space between the header and the actual content.
\documentclass[12pt, a4paper, oneside, openany]{scrbook}
\pagestyle{headings}
%page layout
\setlength{\voffset}{0mm}
\setlength{\topmargin}{0mm}
\setlength{\headsep}{0mm}
\setlength{\oddsidemargin}{0mm}
\setlength{\evensidemargin}{0mm}
\setlength{\textheight}{210mm}
\setlength{\textwidth}{150mm}
\setlength{\marginparwidth}{5mm}
\setlength{\marginparsep}{3mm}
\setlength{\marginparpush}{7mm}
\setlength{\parindent}{5mm}
\setlength{\footskip}{0mm}
\usepackage{fontspec}
\fontspec{Times New Roman}
\usepackage{url}
\linespread{1.5}
\usepackage[acronym]{glossaries}
\parindent 10mm
\parskip 5mm
\usepackage{graphicx}
\graphicspath{{images/}}
\usepackage[a4paper]{geometry}
You can redeclare the sectioning command which you'd like to change and set whatever beforeskip you like:
% !TeX TS-program = lualatex
\documentclass[12pt, a4paper, oneside, openany]{scrbook}
\pagestyle{headings}
\RedeclareSectionCommand[beforeskip=0pt]{chapter}
%page layout
\setlength{\voffset}{0mm}
\setlength{\topmargin}{0mm}
\setlength{\headsep}{0mm}
\setlength{\oddsidemargin}{0mm}
\setlength{\evensidemargin}{0mm}
\setlength{\textheight}{210mm}
\setlength{\textwidth}{150mm}
\setlength{\marginparwidth}{5mm}
\setlength{\marginparsep}{3mm}
\setlength{\marginparpush}{7mm}
\setlength{\parindent}{5mm}
\setlength{\footskip}{0mm}
\usepackage{fontspec}
\fontspec{Times New Roman}
\usepackage{url}
\linespread{1.5}
\usepackage[acronym]{glossaries}
\parindent 10mm
\parskip 5mm
\usepackage{graphicx}
\graphicspath{{images/}}
\usepackage[a4paper]{geometry}
\begin{document}
\chapter{title}
\end{document}
Answer courtesy of https://tex.stackexchange.com/questions/62125/how-to-remove-top-margin-above-tableofcontents. Visit this excellent post to get a comprehensive explanation and alternative methods to do your stuff.
Add the following to your preamble:
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\makeatletter
\let\oldtableofcontents\tableofcontents
\renewcommand{\tableofcontents}{\begingroup%
\patchcmd{\#makeschapterhead}% <cmd>
{\vspace*{50\p#}}% <search>
{}% <replace>
{}{}% <success><failure>
\oldtableofcontents%
\endgroup%
}
\makeatother
The above does a local search-and-replace within #makeschapterhead (replacing \vspace*{50\p#} with nothing, before calling the regular table of contents. The redefinition (search-and-replace) is localized within the scope of the group.

Title page Errors

% Thesis master document
\documentclass[final,12pt,a4paper,oneside]{book}
\setcounter{secnumdepth}{3}
\textheight =24.2 cm
\textwidth =15 cm
\topmargin =-15mm
\usepackage[round]{natbib}
\usepackage{amssymb}
\usepackage{graphics}
\usepackage{graphicx}
\usepackage{epsfig}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{bm}
\usepackage{layout}
\usepackage {mathrsfs}
\usepackage{listings}
\usepackage{float}
\def\hang{\hangindent\parindent}
\def\rf{\par\noindent\hang}
\newtheorem{defin}{Definition}
\newtheorem{theorem}{Theorem}
\newtheorem{result}{Result}
\begin{document}
\baselineskip = 18pt
\pagestyle{plain}
\frontmatter
\include{Title}
\maketitle
\tableofcontents
\listoftables
%\listoffigures
\include{Introduction}
\mainmatter
\include{Chapter1}
\include{Chapter2}
\include{Chapter3}
\include{Chapter4}
\include{Conclusion}
%\include{Appendix}
\backmatter
\include{Bibliography}
\end{document}
I've got the above code in my masterfile as part of my thesis due today. it has been executing properly until now. I accidently deleted the \maketitle command but when I put it back, it won't just execute. I get the error attached. I'm not sure if I placed it in wrongly this time. Can someone please help?

create link on every page of latex file to a specific page

I want to create a link on every page of a latex file, and this link should navigate to a specific page in the documents. Like, create a link for \listoftodos command on every page, so that one can easily navigate to it.
MWE
\documentclass[]{article}
%opening
\title{}
\author{}
\usepackage[draft, colorinlistoftodos]{todonotes}
\begin{document}
\section{one}
\todo[inline]{todo 1}
\newpage
\section{two}
\todo[inline]{todo 2}
\newpage
\listoftodos
\end{document}
One possibility: use the fancyhdr package and add a link to the head or footline:
\documentclass[]{article}
%opening
\title{}
\author{}
\usepackage[draft, colorinlistoftodos]{todonotes}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancypagestyle{plain}[fancy]{}
\renewcommand{\headrulewidth}{0pt}
\cfoot{\protect\hyperlink{todolist}{jump to todo list}}
\usepackage{hyperref}
\begin{document}
\section{one}
\todo[inline]{todo 1}
\newpage
\section{two}
\todo[inline]{todo 2}
\newpage
\phantomsection
\hypertarget{todolist}{}
\listoftodos
\end{document}

Lyx modifying moderncv empty space

I am new on latex and lyx. I have to realize a resume and used moderncv. Do you know how I can have the space behing my picture being reduced ? (The one hatched in red) . As everything is supposed to fit in one page with a cv, it is important for me.
Thanks for your help
%% LyX 2.3.3 created this file. For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{moderncv}
\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage{geometry}
\geometry{verbose,tmargin=1cm,bmargin=1cm,lmargin=1cm,rmargin=1cm}
\usepackage{fancyhdr}
\pagestyle{fancy}
\setcounter{secnumdepth}{2}
\setcounter{tocdepth}{2}
\usepackage{float}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{xmpmulti}
\usepackage{enumitem}
\moderncvtheme[grey]{classic}
\firstname{John}
\familyname{Do}
\title{Title}
\address{adress}{city}
\mobile{+33 6 §§ §§ §§ §§}
\email{john.do#ens.psl.eu}
\photo[100pt]{Mii_Artwork.png}
\makeatother
\usepackage{babel}
\begin{document}
\maketitle
\section{Formation}
\cventry{2021/2022}{Master de Science cognitive}{Ecole normale supérieure rue d'Ulm}{Paris}{France}{}
\end{document}
Quick hack: add \vspace{-1.5cm} after \maketitle :
`
%% LyX 2.3.3 created this file. For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{moderncv}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\geometry{verbose,tmargin=1cm,bmargin=1cm,lmargin=1cm,rmargin=1cm}
\usepackage{fancyhdr}
\pagestyle{fancy}
\setcounter{secnumdepth}{2}
\setcounter{tocdepth}{2}
\usepackage{float}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{xmpmulti}
\usepackage{enumitem}
\moderncvtheme[grey]{classic}
\firstname{John}
\familyname{Do}
\title{Title}
\address{adress}{city}
\mobile{+33 6 §§ §§ §§ §§}
\email{john.do#ens.psl.eu}
\photo[100pt]{example-image}
\makeatother
\usepackage{babel}
\begin{document}
\maketitle
\vspace{-1.5cm}
\section{Formation}
\cventry{2021/2022}{Master de Science cognitive}{Ecole normale supérieure rue d'Ulm}{Paris}{France}{}
\end{document}

Latex chapter refrencing giving the last chapter last section reference

I have a problem referencing a chapter. I used a label bellow each title however, it is not giving the right reference. I tried some fixes but it did not work (nameref, varioref, cleveref)
my latex code is as follows
\documentclass[12pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[french,arabic,english]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\graphicspath{{images/}}
\usepackage{float}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{arabtex}
\usepackage{multirow}
\usepackage{threeparttable}
\usepackage{utf8}
\usepackage{longtable}
\usepackage{url}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage{breakcites}
\usepackage{hhline}
\usepackage{xcolor}
\usepackage{colortbl}
%\usepackage{asect}
\usepackage{tocbibind}
\usepackage{tocloft}
\usepackage{acro}
\input{annexes/abreviations}
\usepackage[colorlinks]{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=blue,
filecolor=magenta,
urlcolor=cyan,
citecolor=violet
}
% ref packages
\usepackage{nameref}
% folowing must be in this order
\usepackage{varioref}
\usepackage{hyperref}
\usepackage{cleveref}
\begin{document}
\input{chapters/chap1.tex}
\input{chapters/chap2.tex}
\input{chapters/chap3.tex}
\input{chapters/chap4.tex}
\bibliographystyle{apalike}
\bibliography{bibliography}
\end{document}
in chapter 1
\chapter{title1}
\label{chap1}
here is defined the label{chap1}
\section{section1}
this is section1
\section{section1}
this is section1
\section{section1}
this is section1
in chapter 3
\chapter{title3}
\label{chap3}
text reference Chapter \ref{chap1}
However, the reference shows the last section of chapter 1
I am using texmaker quick build to compile the code. Here is the complete example on overleaf https://www.overleaf.com/read/rxkmhxcbcgqc
we can also notice that referencing the first chapter does not work.
A minimal non-working example would be
\documentclass{book}
\usepackage[arabic,english]{babel}
\begin{document}
\chapter{title}\label{key}
test \ref{key}
\end{document}
You can work around this problem using the approach from https://tex.stackexchange.com/a/238442/36296
\documentclass{book}
\usepackage[arabic,english]{babel}
\makeatletter
\def\#part[#1]#2{%
\addtocontents{toc}{\xstring\select#language{\main#Arabi#language}}%
\if#rl\SAV##part[\textRL{#1}]{\textRL{#2}}%
\else\SAV##part[\textLR{#1}]{\textLR{#2}}%
\fi}
\def\#spart#1{%
\addtocontents{toc}{\xstring\select#language{\main#Arabi#language}}%
\if#rl\SAV#spart{\textRL{#1}}%
\else\SAV#spart{\textLR{#1}}%
\fi}
\def\#chapter[#1]#2{%
\addtocontents{toc}{\xstring\select#language{\main#Arabi#language}}%
\if#rl\SAV##chapter[\textRL{#1}]{\textRL{#2}}%
\else\SAV##chapter[\textLR{#1}]{\textLR{#2}}%
\fi}
\def\#schapter#1{%
\addtocontents{toc}{\xstring\select#language{\main#Arabi#language}}%
\if#rl\SAV#schapter{\textRL{#1}}%
\else\SAV#schapter{\textLR{#1}}%
\fi}
\makeatother
\begin{document}
\chapter{title}\label{key}
test \ref{key}
\end{document}

Resources