1

I write quite long document \documentclass[a4paper,11pt]{article} where I include pages from other.pdf like:

\documentclass[a4paper,11pt]{article}
...
\begin{document}
\tableofcontents
...
\section{My pictures}   %1
\subsection{Description} %1.1
Some short description
\clearpage

\subsection{Picture of me} %1.2
\begin{figure}
\includepdf[pages=1,scale=1, noautoscale]{other.pdf}
\end{figure}
\clearpage

And what I would like to achieve is: In the table of contents I would like to have all subsection listed:

1. My pictures
  1.1. Description
  1.2. Picture of me

But on the page with Picture of me I don't want to see this subtitle. I tried many things but w/o any good result. It could be resolved with some trick like font size 0, or total text width 0... Just to achieve the desired result. Of course, for a proper solution, I will be so grateful.

What is also important is that included pages must have 100% of actual size and fill all page.

2
  • 1
    \refstepcounter{subsection} \addcontentsline{toc}{subsection}{\protect\numberline{\thesubsection} Picture of me} instead of \szbsection{Picture of me} should sork.
    – leandriis
    Dec 15, 2020 at 11:41
  • It works!! So so so much thank you. I will create a \newcommand using this!
    – pi.314
    Dec 15, 2020 at 11:50

1 Answer 1

1

You could use \refstepcounter{subsection} \addcontentsline{toc}{subsection}{\protect\numberline{\thesubsection}Picture of me} or define your own command as shown in the following MWE. In this example code, I also included \phantomsection from the hyperref package. If you don't use this package, simply remove \phantomsection from the definition of \myhiddensubsection.

Side note: I also removed the figure environment since I assume you don't actually want the image/pdf file to float away from where it was used in the code.

\documentclass[a4paper,11pt]{article}
\usepackage{graphicx}
\usepackage{hyperref}

\newcommand{\myhiddensubsection}[1]{%
    \phantomsection%
    \refstepcounter{subsection}%
    \addcontentsline{toc}{subsection}{\protect\numberline{\thesubsection}#1}%
    }
\begin{document}
\tableofcontents

\section{My pictures}
\subsection{Description} 
Some short description
\clearpage

\myhiddensubsection{Picture of me}


\includegraphics{example-image}

\clearpage

\subsection{next subsection} 

\end{document}
2
  • Just remove the space just before #1. This space appears in ToC and titles are not aligned with those not-hidden.
    – pi.314
    Dec 15, 2020 at 12:33
  • @pi.314: Thanks for pointing this out. I totally overlooked the extra space.
    – leandriis
    Dec 15, 2020 at 12:35

You must log in to answer this question.

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