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}
  • 2
    Hm, why are you using the starred version? \section{A} would be automatically printed using \tableofcontents. – Johannes_B Jul 19 '16 at 12:58
  • Numbers of section are big and don't look well. And I need list of contents in Slovak no English. – Ľubomír Masarovič Jul 19 '16 at 12:59
  • 1
    You can suppress the numbers with \setcounter{secnumdepth}{0} – Ulrike Fischer Jul 19 '16 at 13:01
  • But it's in English - I want to have got it in Slovak. – Ľubomír Masarovič Jul 19 '16 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 Jul 19 '16 at 13:10
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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.