change page nchange page number between index and normal pagesumber between index and normal pages

106 views
Skip to first unread message

Matteo Ghetta

unread,
Jan 22, 2016, 6:19:56 AM1/22/16
to sphinx-users
Hi all,
I'm struggling with an apparently simple issue.

What I would like to achieve is to have roman number for the index pages and arabic number for the rest of the document. (sphinx -> latexpdf)

I looked for a solution but I did not find anything.

Am I missing something?

Thanks!

Matteo

Jan Ulrich Hasecke

unread,
Jan 22, 2016, 8:19:42 AM1/22/16
to sphinx...@googlegroups.com
If you know how to achieve this in latex (eg. by \frontmatter,
\mainmatter, \backmatter) you can simple put these commands into your
source like this:


.. raw:: latex

\frontmatter


juh

--
Software-Dokumentation mit Sphinx
http://www.amazon.de/dp/1497448689/
Paperback: 224 Seiten

Matteo Ghetta

unread,
Jan 22, 2016, 9:27:35 AM1/22/16
to sphinx-users, juh+sphi...@mailbox.org

If you know how to achieve this in latex (eg. by \frontmatter,
\mainmatter, \backmatter) you can simple put these commands into your
source like this:


.. raw:: latex

   \frontmatter

actually I'm pretty new to latex.. :)
I tried your solution adding a .. raw:: latex \frontmatter to one of my rst files (I have 9 of them, so 9 chapters).
In the final pdf generated, **all** the different chapters are recognized as \frontmatter, so the whole pdf has no *real* chapters..

Am I missing something?

Thanks again!

Jan Ulrich Hasecke

unread,
Jan 22, 2016, 9:27:35 AM1/22/16
to Matteo Ghetta, sphinx-users
\frontmatter marks foreword, tableofcontents etc.

Before you start with your first chapter insert:

.. raw:: latex

\mainmatter

This will start the normal part of your document.

If you want to separate appendices, eg. index, insert this:

.. raw:: latex

\backmatter

If you want to customize the latex output of Sphinx, have a look at the
available LaTeX documentation.

Kevin Dunn

unread,
Jan 22, 2016, 9:38:25 AM1/22/16
to sphinx...@googlegroups.com, Matteo Ghetta
Hi Matteo,

I found these two links to be useful when looking at this issue:

The last one will be helpful if you are new to LaTeX.

Kevin 

Matteo Ghetta

unread,
Jan 22, 2016, 5:59:30 PM1/22/16
to sphinx-users, matteo...@gmail.com, juh+sphi...@mailbox.org

Il giorno venerdì 22 gennaio 2016 15:27:35 UTC+1, Jan Ulrich Hasecke ha scritto:


Am 22.01.2016 um 14:48 schrieb Matteo Ghetta:
>
>     If you know how to achieve this in latex (eg. by \frontmatter,
>     \mainmatter, \backmatter) you can simple put these commands into your
>     source like this:
>
>
>     .. raw:: latex
>
>        \frontmatter
>
>
> actually I'm pretty new to latex.. :)
> I tried your solution adding a .. raw:: latex \frontmatter to one of my
> rst files (I have 9 of them, so 9 chapters).
> In the final pdf generated, **all** the different chapters are
> recognized as \frontmatter, so the whole pdf has no *real* chapters..
>
> Am I missing something?
>

\frontmatter marks foreword, tableofcontents etc.

Before you start with your first chapter insert:

.. raw:: latex

   \mainmatter

This will start the normal part of your document.

If you want to separate appendices, eg. index, insert this:

.. raw:: latex

   \backmatter

ah ok I get it now, thanks!

just one more question: if I have 10 chapters, and I want to divide the index so that there would appear:

cap1....page 1
cap2....page 10
.......

cap1 (but in fact it is the cap7)... page 40
cap2 (but it is cap8)...page 45


if I add
.. raw:: latex
    \mainmatter
    \setcounter{chapter}{0}

the cap7 is shown as cap1 (and it is fine) but the page numbering starts again from 1

it there a way to set the counter to begin again but not the page numbering?

Thanks again!

Matteo Ghetta

unread,
Jan 22, 2016, 5:59:31 PM1/22/16
to sphinx-users, matteo...@gmail.com

Hi Matteo,

I found these two links to be useful when looking at this issue:

The last one will be helpful if you are new to LaTeX.

thanks I will have a look at that!

Matteo Ghetta

unread,
Jan 25, 2016, 4:50:39 PM1/25/16
to sphinx-users, matteo...@gmail.com
hey guys..
it seems I celebrate too early..

with the suggestion of the .. raw:: latex role I can improve a lot of things, so thanks!

But I have another problem/question:

in the **conf.py**  I have specified that the final result should be compiled as a book:

latex_documents = [
  ('index', 'project.tex', u'project User Manual',
   u'project', 'book'),
]

but in this way I cannot forse the index page to have roman numbers and each chapter arabic ones.

I can solve by replacing book with manual:

latex_documents = [
  ('index', 'project.tex', u'project User Manual',
   u'project', 'manual'),
]

but the question is: why one cannot force the page number style with the books?

Thanks again
Reply all
Reply to author
Forward
0 new messages