you can suppress the automatically generated toc entry and replace it.
to suppress, add this command to your preamble:
\DeclareRobustCommand{\SkipTocEntry}[4]{}
if you are using hyperref, change the [4]
to [5]
-- this is the number of elements in the toc entry to be suppressed.
immediately before the line that generates the toc entry, insert the line
\addtocontents{toc}{\SkipTocEntry}
if applying it to a chapter, and you use \include
to insert your chapters, it must be in the same file as the \chapter
command; if you put it in the driver file, the timing will be off, and the chapter entry from the next chapter will be suppressed instead.
a replacement entry should be inserted immediately after the line that generated the toc entry, in order to ensure that the page number has been resolved correctly.
define a counter \newcounter{prevpage}
in the preamble. when setting up the replacement toc entry,
\setcounter{prevpage}{\value{page}}
\addtocounter{prevpage}{-1}
then use \addtocontents{toc}{xxx}
where xxx
is the line that was automatically generated (and suppressed) that you can copy from the .toc
file, except that you should replace the assigned page number by {\theprevpage}
. if you had to \protect
some commands in the text of the original heading, you should do the same in the replacement toc entry.
say this line appears in the toc (the example is from a test using amsbook
):
\contentsline {section}{\tocsection {}{5}{Section title}}{10}
the page number is {10}
. what you'd put in your file as a replacement is
\addtocontents{toc}{\protect\contentsline {section}{\protect\tocsection {}{5}{Section title}}{\theprevpage}}
observe that \contentsline
and \tocsection
do need to be \protect
ed.
(i took this example from a test using amsart.cls
, but the principle should be the same regardless of the document class. just copy what's in the .toc
file from your first run, and modify it appropriately.)
EDIT: the OP created an admirable macro, \transsection
to handle this. what follows is a self-contained example file demonstrating the use of his macro with the book
class.
\documentclass{book}
\usepackage{verbatim}
\DeclareRobustCommand{\SkipTocEntry}[4]{}
\newcounter{prevpage}
\newcommand{\transsection}[1]{%
\addtocontents{toc}{\SkipTocEntry}%
\section{#1}%
\setcounter{prevpage}{\value{page}}\addtocounter{prevpage}{-1}%
\addtocontents{toc}{%
\protect\contentsline {section}{%
\protect\numberline {\thesection}#1}{\theprevpage}}}
\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\chapter{First}
\section{First section}
some text
\clearpage
\transsection{Test section}
We want this section to have a page number one less than the
real one. This is from question 55645 in TeX.SX, where the
author is setting an Arabic page on the page before the
English translation page, and wants the TOC to show that
page number.
\vspace{1\baselineskip}
\verbatiminput{\jobname.tex}
\end{document}
Since you want ToCs in sections, you would have to use \dosecttoc
, and \secttoc
, instead of \doparttoc
and \parttoc
.
However, the minitoc
documentation says that section ToCs are not available for the report
and book
classes. minitoc
will only give ToCs for the highest sectioning commands in the hierarchy of the class. So I guess, no luck here with this package.
Best Answer
OK, I think I got it, thanks to answer #47241 How to remove the self-reference of the ToC from the ToC?:
And indeed, seems to work for above MWE too:
Hope this is the way to do this
:)
Cheers!