2

Good afternoon

I have got pages and on every page I have got \section*{...text...}. I would like to make list of these sections with name and number of page. Can I do it automatically? Just one imperative.

Do you know it?

\documentclass[10pt,a6paper]{book}

\usepackage[utf8]{inputenc}
\usepackage[main=english,slovak]{babel}
\usepackage[cm]{fullpage}
\usepackage[a6paper, top=10mm, left=10mm, right=10mm,    
bottom=10mm,foot=5mm,marginparsep=0mm,showframe]{geometry}

\usepackage{tipa}
\usepackage{tabularx,booktabs}
\usepackage{multirow}
\usepackage{rotating}
\usepackage{graphicx}
\usepackage{array}

\begin{document}
\catcode`\-=12
\sloppy


\section*{\foreignlanguage{slovak}{A}}
\newpage

\section*{\foreignlanguage{slovak}{B}}
\newpage

\section*{\foreignlanguage{slovak}{C}}
\newpage

\section*{\foreignlanguage{slovak}{D}}
\newpage

\section*{\foreignlanguage{slovak}{E}}
\newpage


\end{document}
8
  • 2
    Hm, why are you using the starred version? \section{A} would be automatically printed using \tableofcontents.
    – Johannes_B
    Commented Jul 19, 2016 at 12:58
  • Numbers of section are big and don't look well. And I need list of contents in Slovak no English. Commented Jul 19, 2016 at 12:59
  • 1
    You can suppress the numbers with \setcounter{secnumdepth}{0} Commented Jul 19, 2016 at 13:01
  • But it's in English - I want to have got it in Slovak. Commented Jul 19, 2016 at 13:05
  • 1
    @ĽubomírMasarovič : it's because of main=english in your options for babel. You should thus change the language outside of the command.
    – ebosi
    Commented Jul 19, 2016 at 13:10

1 Answer 1

3

Perhaps this is a possible solution, using a \section*{foo}* variant defined with xparse's \NewDocumentCommand -- the syntax is unusual, but the normal \section* is preserved then.

\documentclass[10pt,a6paper]{book}

\usepackage[utf8]{inputenc}
\usepackage[main=english,slovak]{babel}
\usepackage[cm]{fullpage}
\usepackage[a6paper, top=10mm, left=10mm, right=10mm,    
bottom=10mm,foot=5mm,marginparsep=0mm,showframe]{geometry}

\usepackage{tipa}
\usepackage{tabularx,booktabs}
\usepackage{multirow}
\usepackage{rotating}
\usepackage{graphicx}
\usepackage{array}

\usepackage{xparse}
\providecommand{\phantomsection}

\makeatletter
\let\latex@@section\section
\RenewDocumentCommand{\section}{soms}{%
  \IfBooleanTF{#1}{%
    \IfBooleanT{#4}{%
      \addcontentsline{toc}{section}{{#3}}%
    }%
    \latex@@section*{#3}%
  }{%
    \IfValueTF{#2}{%
      \latex@@section[#2]{#3}%
    }{%
      \latex@@section{#3}%
    }
  }%
}    


\makeatother

\begin{document}
\tableofcontents
\catcode`\-=12
\sloppy


\section*{\foreignlanguage{slovak}{A}}*
\newpage

\section*{\foreignlanguage{slovak}{sobota}}*
\newpage

\section*{\foreignlanguage{slovak}{nedel'a}}*
\newpage

\section*{\foreignlanguage{slovak}{D}}*
\newpage

\section*{\foreignlanguage{slovak}{E}}*
\newpage


\end{document}

enter image description here

You must log in to answer this question.

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