Latex section without a number in the table of contents - latex

I would like to create a table of contents for a bachelorthesis but dont wanna nummerate all points of it.
The abstract for example should be in the toc but not with a number.
I write my thesis in the documentclass article where i dont have the chance to use \chapter.
Is there an easy way to fix the problem?
Thank you!

You can use \section*{} which create a section without the numeration.
However, it will not be present in the table of content.
You can manually add it with \addcontentsline{toc}{section}{\protect\numberline{}Your section name}.
For example for an abstract, an introduction, two numbered sections, and a conclusion, you can do:
\documentclass{article}
\begin{document}
\tableofcontents
\section*{Abstract}
\addcontentsline{toc}{section}{\protect\numberline{}Abstract}
\section*{Introduction}
\addcontentsline{toc}{section}{\protect\numberline{}Introduction}
\section{Section 1}
\section{Section 2}
\section*{Conclusion}
\addcontentsline{toc}{section}{\protect\numberline{}Conclusion}
\end{document}

Related

Use \newcommand without the text styles added to it

This is a weird question and I don't know if I was able to formulate it that well.
So, I declare a newcommand somewhere like this:
\newcommand{\examplecommand}{\textbf{\textit{exampletext}}}
It'll be used quite many times this way.
I'm trying to also use it in one place in the document, wanting to format it in a different way (with \textsc{}, and none of the bolding and italicization)
I tried doing stuff like
\textsc{\examplecommand}
But that doesn't work, it still somehow prioritizes the formatting in the command declaration.
How can I use the command without changing the declaration, but with different formatting?
EDIT (MWE):
document.tex
--------------------
\documentclass{book}
\usepackage{fancyhdr}
\usepackage{blindtext}
\newcommand{\booktitle}{} % create it empty at first, so that the files can change it
\newcommand{\textbfit}[1]{\textbf{\textit{#1}}} % combine bold and italic in one
\fancypagestyle{plain}{
\fancyhf{}
\fancyhead[RO,RE]{\textsc{\booktitle}}
\renewcommand{\headrulewidth}{2pt}
}
\begin{document}
\pagestyle{plain}
\chapter{example1}
\input{doc1}
\chapter{example2}
\input{doc2}
\chapter{example3}
\input{doc3}
\end{document}
doc1.tex
--------------------
\renewcommand{\booktitle}{\textbfit{``Title 1''}}
\booktitle\ is a very nice book, it's really great, buy it etcetcetc
\blindtext
doc2.tex
--------------------
\renewcommand{\booktitle}{\textbfit{``Title 2''}}
\booktitle\ is a very nice book, it's really great, buy it etcetcetc
\blindtext
doc3.tex
--------------------
\renewcommand{\booktitle}{\textbfit{``Title 3''}}
\booktitle\ is a very nice book, it's really great, buy it etcetcetc
\blindtext
The reason I want to be able to do this:
I have 12 documents that I wrote in a single-document form, and now I wish to make them work both in the single-document form (all of them having a separate .tex file that compiles them as a single document), and a form that puts them all into a large file.
I was using that \booktitle command across all of them, since they are all similar in general structure. And now when I wanted to also convert them into book form, I discovered I can use it to change the top right corner text inside the header (see that the definition of the plain fancypagestyle uses that command inside its fancyhead), but, in there, I want to use it with \textsc
The reason I don't want to change my command is because it means changing it across all of the documents inside, and I was just thinking I could do \textsc{\booktitle} and be done with it
You could temporarily switch off your \textbfit command:
\documentclass{book}
\usepackage{fancyhdr}
\usepackage{blindtext}
\newcommand{\booktitle}{} % create it empty at first, so that the files can change it
\newcommand{\textbfit}[1]{\textbf{\textit{#1}}} % combine bold and italic in one
\fancypagestyle{plain}{
\fancyhf{}
\fancyhead[RO,RE]{
\begingroup
\let\textbfit\relax
\textsc{\booktitle}
\endgroup
}
\renewcommand{\headrulewidth}{2pt}
}
\begin{document}
\pagestyle{plain}
\chapter{example1}
\renewcommand{\booktitle}{\textbfit{``Title 1''}}
\booktitle\ is a very nice book, it's really great, buy it etcetcetc
\blindtext
\end{document}

Add a custom word to a cross reference in LaTex

Good morning!
I've been searching for a time but I can't reach a solution to my problem. I'm writing my master thesis, and I want to add custom words to my references, I mean, if I want to ref the only table in my document (\label{table:test} for example), I usually do \ref{table:test}, getting as a result just a clickable number 1.
However, I need to set a global option in order to, always I refer to a table, for example, I get {custom word} 1(1 for the first table). This custom word surely will be Table, but I can desire to use Figure(in English) or Imagen (in spanish), for ref figures.
Thanks you very much in advance!
The cleveref package will automatically add the correct words and adapt to the language of your document:
\documentclass[spanish]{article}
\usepackage{babel}
\usepackage{hyperref}
\usepackage[noabbrev,nameinlink]{cleveref}
\begin{document}
\begin{figure}
\caption{content...}
\label{key}
\end{figure}
\cref{key}
\end{document}

LATEX: delete the number of page from the backmatter

im tring to delete the page number from my \backmatter sequence. I've succeded to do this, writing this code:
\begin{document}
.
.
.
\backmatter
\begingroup
\makeatletter
\let\ps#plain\ps#empty
\addcontentsline{toc}{chapter}{Allegati}
\input{Allegati}
\input{Bibliografia}
\listoffigures
\listoftables
\listof{grafico}{Elenco dei grafici}
\endgroup
\end{document}
But, I don't know why, the last page of my document still have his number. In the code above the last page is a graphic list, but if I change the order of my sequence, for example putting the bibliography in the last position, the this element will present the page number. I'm writing this document using the book class.
Someone can help me?
thanks
As you did not provide a MWE (Minimal Working Example) I can just guess what your document's preamble contains.
Have a look at this code please:
\documentclass{book}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancypagestyle{plain}{
\lhead{}
\chead{}
\rhead{}
\lfoot{}
\cfoot{}
\rfoot{}
}
\begin{document}
text
\newpage
text
\newpage
\backmatter
\begingroup
\pagestyle{plain}
\addcontentsline{toc}{chapter}{Allegati}
\listoffigures
\listoftables
%\listof{grafico}{Elenco dei grafici}
\endgroup
\end{document}
EDIT1:
This way you redefine the plain-style that is used by every chapter-page in your document.
If you do not want to change it document-wide, your approach is correct; just add a \clearpage before the last \endgroup. It won't create a new page, but delete the pagenumber. Btw, if you don't really need the \begingroup \endgroup leave it out, this will also delete the last page number.
END-EDIT1
A few things to note:
If you use plain book-class, you can use fancyhdr for setting a
page style like in the above example. Later just load the wanted
pagestyle and from there on it will be used.
If you want to write a document according to the modern
standard of LaTeX, maybe think about using a KOMA-class, which
provides great functions for changing the page style (and often they
also work better ;))
For me this MWE does work, having no pagenumber on the last page; if it does not for you, please give us more information about your document.

glossaries package and footnote in LaTeX

I am currently stuck, having two separate glossaries: main & acronyms. Acronyms glossary prints footnotes on first use in the text, but main glossary does not. Is there any way to make any other glossary than acronyms to print footnote on first use of the term? I don't get how to do it.
Here is the code example compiled with TeXnic Center and MiKTeX 2.7:
\documentclass{article}
\usepackage{index}
\usepackage[toc,style=long3colheaderborder,footnote,acronym]{glossaries}
\makeindex
\makeglossaries
\newglossaryentry{appdomain}{name={application domain}, description={app Domain Description...}}
\newglossaryentry{sample}{name={[has been inserted aaa]},description={testing testing 123}}
\newacronym{aca}{aca}{a contrived acronym}
\begin{document}
\section{this is a test section}
This is the test line... a \gls{sample} \gls{appdomain}
\index{entry} and \gls{aca}
\thispagestyle{empty}\cleardoublepage
\printglossary[type=main,title={Glossary},toctitle={Glossary}]
\thispagestyle{empty}\cleardoublepage
\printglossary[type=\acronymtype,title={List of Abbreviations},toctitle={List of Abbreviations}]
\printindex
\thispagestyle{empty}\cleardoublepage
\end{document}
I want sample and appdomain either contain a footnote with description or a footnote stating: please refer to Glossary
Many thanks,
Ovanes
In short, with the glossaries package, you can't get footnotes on the first use for non-acronym glossaries.
However, you can redefine some commands in the preamble (after you \usepackage{glossaries}) to get what you want:
\makeatletter
\renewcommand{\gls#main#displayfirst}[4]{
#1#4\protect\footnote{#2}
}
\makeatother
But that will be really fragile.
I think there is an easier way of doing this. Maybe it's new, but
\defglsdisplayfirst[main]{#1#4\protect\footnote{#2}}
appears to achieve the exact same thing (correct me if I'm wrong). See the glossaries manual, version 2.03, subsection 2.4.1 changing the format of the text.
Unfortunately, it appears commands like \gls or \autoref does not work in those footnotes.
Following is a good technique, to put a footnote stating where the definitions are:
\label{nom} %put this on the page your term appears, so that it can collect page number
\newcommand{\g}{\footnote{For all abbreviations see the glossary on page \pageref{nom}.}}
I've found this from here.

Latex Table of Contents Links to Wrong Section

I have a section followed by a table of contents like so:
\section{Section1}
ABC.
\addcontentsline{toc}{section}{Table of Contents}
\tableofcontents
\newpage
\addcontentsline{toc}{section}{List of Figures}
\listoffigures
\newpage
\section{Section2}
DEF.
\section{Section3}
GHI.
My issue is that the "Table of Contents" and "List of Figures" entries in the table of contents link (in the generated pdf) to the wrong place in the file. They both link to the first section section on page 1. The entry in the table is correct (TOC says page 2 and LOF says page 3), but the link goes to the wrong place.
You'll need to use the \phantomsection command:
\section{Section1}
ABC.
\phantomsection
\addcontentsline{toc}{section}{Table of Contents}
\tableofcontents
\newpage
\phantomsection
\addcontentsline{toc}{section}{List of Figures}
\listoffigures
\newpage
\section{Section2}
DEF.
\section{Section3}
GHI.
See the hyperref manual.
If you're doing this for the bibliography, list of tables or list of figures,
\usepackage[nottoc]{tocbibind}
should fix it, without the wrong-page problems. Otherwise, I havent come across a better solution than \phantomsection with \addcontentsline.
This behavior is due to the fact that \tableofcontents inserts a page break before writing the contents. Hence, your PDF bookmark will point to the page before. Depending on your document class, you can manually insert a number of \newpage commands to keep \tableofcontents from adding another. One or two should be sufficient.
I know, it is a hacky solution, and there might exist a package to solve the problem, but this is how I work around the problem.

Resources