LaTeX remove subsection from TOC - latex

I use the following code in LaTeX to set the level of contents in the table of contents:
\setcounter{secnumdepth}{2}\newcommand{\restoretoc}\addtocontents{toc}
{\protect\vspace*{2.5em}{\setcounter{tocdepth}{1}{\setcounter{secnumdepth}{2}}}
The ouput is the following:
The counter disappears but subsubtitle and page number are still there. How to remove all the counter, title and page number in the table of contents for the subsubsection?

A first simple suggestion:
\documentclass{book}
\begin{document}
\tableofcontents
\chapter{First}
\section{First first}
\section{First second}
\subsection*{First second first}
%\setcounter{subsection}{1}
\subsection{First second second}
\end{document}
This way, the "starred" \subsection* (or section or chapter) does not appear in the table of contents.
Furthermore, uncommenting the line \setcounter{subsection}{1} (and editing the digit 1 in it) you can play with the following subsections number as you prefer. Compile twice to test this, because table of contents file requires it to update the output pdf or dvi file.
What I wrote about subsections applies to subsubsections too if counter secnumdepth is set to 3 or more.

Related

paracol and footnote placing in Latex

For my current project I need two text lined up in two column. The idea is that one column shows the original language and the second column its translation, neatly lined up line by line. The package paracol does what I want except for one thing: footnote placement.
If one of the columns has a footnote and the other hasn't, the lines of the original and the translation do not stay together. The footnote disrupts the lining up of lines.
This is an example in which you can see that "some other text that should be next to the line in the left column" is not lined up with the lines of the original. All because of the footnote.
\documentclass[twoside,a4paper,11pt]{book}
\usepackage{paracol}
\usepackage{lipsum}
\begin{document}
\begin{paracol}{2}
\lipsum[1-2]
\switchcolumn
\lipsum[1-2]
\switchcolumn
text with footnote\footnote{the footnote}
and some other text
\switchcolumn
the translation without footnote
some other text that should be next to the line in the left column
\end{paracol}
\end{document}
As you can see, the footnote disrupts the alignment of lines. How to remedy this?
I found the solution to my own problem by adding the following line after loading the paracol package:
\footnotelayout{p}
This ensures that footnotes are layed out for the whole page instead of the default of per column.
(Since I also added footmisc with the perpage parameter, I also had to delete the perpage parameter and add this:
\usepackage{everypage}
\AddEverypageHook{\setcounter{footnote}{0}} % resets footnote counter on every page
)

How to start new line after paragraph title in Lyx?

I am using the Lyx document processor for LaTeX.
I need to use the Paragraph environment (because I have Subsubsubsections), and I want the paragraphs to appear in the Table of Contents.
I managed to get the Paragraph to appear in the TOC by changing the Document Settings. However, the text right after the title does NOT start in a new line.
I sort of fixed this by inserting ERT (LaTeX code) \newline.
However, now I have a problem because the page number for the paragraphs in the table of contents is also being shown on the next line! (Instead of to the right of the page, under the other page numbers.)
So how do I get the paragraph's body text to start from a new line, without affecting the TOC?
Thank you.
To get new lines after paragraphs, you need to re-define the paragraph command.
Go to
Document -> Settings -> Latex Preamble
and add
\renewcommand\paragraph{\#startsection{paragraph}{4}{\z#}%
{-3.25ex\#plus -1ex \#minus -.2ex}%
{1.5ex \#plus .2ex}%
{\normalfont\normalsize\bfseries}}
Src: http://www.latex-community.org/forum/viewtopic.php?f=5&t=1383
Modify the second and third lines to increase or decrease the space before and after the paragraph title.
For additional information about \#startsection (in case you need more tweaks)
http://infohost.nmt.edu/tcc/help/pubs/nmtthesis/old/annotated/at.startsection.html

How to suppress subsections in the table of contents in latex-beamer?

Assume I have some sections within my latex-beamer presentation. Some of these sections contain subsections, others do not. So it looks very weird in the table of contents.
How can I suppress subsections in the table of contents?
To keep a specific subsection out of the index use:
\subsection*{...}
To remove all subsections from the TOC only, use: \tableofcontents[hideallsubsections] (added from another answer)
To hide subsections use the pretty self-explanatory:
\tableofcontents[hideallsubsections]
The same as in the other two answers can also be achieved using \setcounter{tocdepth}{1}, before (or after) \begin{document}: try to compile the following code, then delete or comment the line marked with %%% and compile again (once, or twice if necessary) to see the difference.
\documentclass{beamer}
\usetheme{Goettingen}
\setcounter{tocdepth}{1} %%%
\begin{document}
\frame{\tableofcontents}
\section{First}
\begin{frame}
A
\end{frame}
\section{Second}
\subsection{One only}
\begin{frame}
B
\end{frame}
\end{document}
At the same way as using \tableofcontents[hideallsubsections], the subsections disappear in the frame where the \tableofcontents is, but not in the sidebar (if present in the theme you use). The same, again, with local use of starred \subsection*{Subsection Title}.

Increase page numbers in LaTeX Beamer

in LaTeX Beamer, the total number of slides includes those that only contain the table of contents before each section/subsection, which increases the total number of slides unnecessarily. Is there any way to prevent this?
In other words: I don't want slides containing the TOC to have page numbers.
Kind regards,
mefiX
Add the line
\addtocounter{framenumber}{-1}
on each frame you wish to exclude from total count.
See also this other Question here on Stackoverflow, which might assist you further.
The frame option noframenumbering will exclude certain frames from increasing the framenumber. I would recommend to use it in combination with the plain option, otherwise it might look that the frames with the toc will show the same frame number as the frame before.
\documentclass{beamer}
\setbeamertemplate{footline}[frame number]
\AtBeginSection[]{%
\begin{frame}[noframenumbering,plain]
\tableofcontents[currentsection]
\end{frame}
}
\begin{document}
\section{title}
\begin{frame}
\end{frame}
\end{document}
Add [plain] to not display the header and the footer. Finally, add \addtocounter{framenumber}{-1} to not increment page number.
\AtBeginSection[]{%
\begin{frame}[plain]
\addtocounter{framenumber}{-1}
\tableofcontents[currentsection]
\end{frame}
}

Ignoring page numbers in backup slides

I am using the beamer document class in latex to make a presentation. I will have a number of back up slides which are there for offline viewing, reference etc. Beamer has a feature that shows the progress through the presentation as {page#}/{total pages} on each slide. I would really like it if {total pages} was equivalent to my total number of pages w/out counting the back up slides (I don't want to discourage my audience on the first page!). Does anyone know how this can be done?
This can now be achieved with the following option on all "backup" slides:
\begin{frame}[noframenumbering]{My Title}
\end{frame}
Source
This will cause the final number (e.g. 25/25) to be displayed on such pages.
As always, a matter of taste.
This can be done with the appendixnumberbeamer package. Just add \usepackage{appendixnumberbeamer} to the preamble and use \appendix before the first backup slide.
I have defined two commands to do this:
\newcommand{\beginbackup}{
\newcounter{framenumbervorappendix}
\setcounter{framenumbervorappendix}{\value{framenumber}}
}
\newcommand{\backupend}{
\addtocounter{framenumbervorappendix}{-\value{framenumber}}
\addtocounter{framenumber}{\value{framenumbervorappendix}}
}
You can then use \beginbackup and \backupend before and after your backup slide to adjust the number of slides.
For my beamer template I also like to add
\setbeamertemplate{footline}{
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
\usebeamerfont{author in head/foot}\insertshortauthor~~(\insertshortinstitute)
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
\usebeamerfont{title in head/foot}\insertshorttitle
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}%
\usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em}
\insertframenumber{} \hspace*{2ex} % hier hat's sich geändert
\end{beamercolorbox}}%
\vskip0pt%
}
in the definition of the \beginbackup command to hide to total page number in the backup slides, otherwise you'll get something like "24/18".
Using all this, your slides will be numbered like "x/Y" for all slides before the backup, where Y is the total number of slides before the first backup slide, and the backup slides will continue the numbering of the previous slides.
To manually fix the total frame count to a certain number, say 25, you could add the following command
\renewcommand{\inserttotalframenumber}{25}
right after the \begin{document} command.
You can also add the \appendix command right before the beginning of your backup slides, so that the corresponding sections/subsections do not appear in the table of contents/navigation structure.
It should be possible to tweak the renewcommand above so that it automatically uses the last frame number before the appendix, but I don't know how to do it.
Just insert
\renewcommand{\inserttotalframenumber}{\pageref{lastslide}}
after \begin{document}, and place the marker
\label{lastslide}
on your last slide.
You can put all of your backup slides in appendix and use the appendixnumberbeamer package.
\documentclass[12pt]{beamer}
\usepackage{appendixnumberbeamer}
\begin{document}
\begin{frame}{Frames that counts}
\end{frame}
\appendix
\begin{frame}{Backup slides}
\end{frame}
\end{document}
Fanfan, thanks for your answer, your answer steered me to this sty file that one can include in a beamer document class that will automatically count only the number of frames before the appendix, and then restart the a separate count for the appendix slides, pretty neat.
http://www.ensta.fr/~lelong/Latex/appendixnumberbeamer.sty
Thanks also to Jérôme LELONG for having this available online.
The great command \insertpresentationendpage will take care of your problem. Just place \appendix at the begin of your backup slides.
\documentclass[t]{beamer}
\usepackage[absolute,overlay]{textpos}
\setbeamertemplate{navigation symbols}{}
\def\insertpresentationendframe{\inserttotalframenumber}
\makeatletter
\g#addto#macro{\appendix}{\immediate\write\#auxout{\string\#writefile{nav}{\noexpand\headcommand{\noexpand\def\noexpand\insertpresentationendframe{\the\c#framenumber}}}}}
\makeatother
\setbeamertemplate{footline}{%
\begin{picture}(54,12.5)(0,0)
\put(0.9,0.52){%
\begin{minipage}[b][12.5mm][c]{112.5mm}
\raggedleft
\insertframenumber/\insertpresentationendframe
\end{minipage}
}
\end{picture}
}
\begin{document}
\begin{frame}
slide in the main part
\only<2>{blub}
\end{frame}
\appendix
\section*{Backup}
\begin{frame}
\frametitle{backup}
not counting in the total frame number
\end{frame}
\end{document}
Another possibility - which was recently added to beamer - is to use the appendixframenumber template:
\documentclass[t]{beamer}
\setbeamertemplate{footline}{
\hfill%
\usebeamercolor[fg]{page number in head/foot}%
\usebeamerfont{page number in head/foot}%
\setbeamertemplate{page number in head/foot}[appendixframenumber]%
\usebeamertemplate*{page number in head/foot}\kern1em\vskip2pt%
}
\begin{document}
\begin{frame}
slide in the main part
\only<2>{blub}
\end{frame}
\appendix
\section*{Backup}
\begin{frame}
\frametitle{backup}
not counting in the total frame number
\end{frame}
\end{document}

Resources