LaTeX forum ⇒ Text FormattingTable of Contents Formatting Topic is solved

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
samirandam
Posts: 7
Joined: Sat Oct 10, 2015 7:47 pm

Table of Contents Formatting

Postby samirandam » Sat Oct 10, 2015 7:58 pm

Dear All,

I want to enclose the "Part" in Table of Contents of a book type document by under and over lines. However, the other texts (such as, chapters, sections, subsections etc.) should remain as it is with default formatting). I am pasting the minimal working code in this post. Could anybody please help me to achieve what I am looking for?



  1. \documentclass{book}
  2.  
  3. \begin{document}
  4.  
  5. \author{Author A and Author B}
  6. \title{Book Title}
  7. \maketitle
  8.  
  9. \tableofcontents
  10.  
  11. \part{First Part}
  12. \chapter{Chapter 1}
  13.  
  14. \end{document}

Tags:

User avatar
Johannes_B
Site Moderator
Posts: 3584
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Sun Oct 11, 2015 10:12 am

Hi and welcome,

you can do something like the following:
  1. \documentclass{book}
  2.  
  3. \newcommand{\tocline}{\addtocontents{toc}{\protect\begingroup%
  4. \protect\centering\protect\huge\protect\rule{.8\textwidth}{.6pt}\protect\par
  5. \protect\endgroup}}
  6. \begin{document}
  7.  
  8.  
  9. \tableofcontents
  10.  
  11. \tocline
  12. \part{First Part}
  13. \tocline
  14. \chapter{Chapter 1}
  15. \part{Second Part}
  16. \chapter{Chapter 2}
  17. \part{Third Part}
  18. \chapter{Chapter 3}
  19.  
  20. \end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

samirandam
Posts: 7
Joined: Sat Oct 10, 2015 7:47 pm

Postby samirandam » Sun Oct 11, 2015 11:10 am

Hi Johannes_B,

Thank you. The solution you provided is working fine with minor modification according to my requirement. I changed \huge to \small to reduce the gap.

Thank you once again.

Thanks
Samiran
Last edited by Stefan Kottwitz on Sun Oct 11, 2015 11:29 am, edited 1 time in total.
Reason: typo, code marked

User avatar
Stefan Kottwitz
Site Admin
Posts: 8529
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Sun Oct 11, 2015 11:33 am

Hi Samiran,

welcome to the forum!

Nice to see that Johannes could provide a solution. By the way, I prefer the scrbook class over book, as it is much more flexible. We can even make headings with a colored background there.

Let us know if there would be further challenges with writing such a larger book like document. I'm always interested in how good or hard is LaTeX for us users.

Stefan
Site admin

samirandam
Posts: 7
Joined: Sat Oct 10, 2015 7:47 pm

Postby samirandam » Mon Oct 12, 2015 2:00 pm

Hi Stefan,

It is very nice to be greeted into the group and thanks for your thoughtful suggestion.

Actually, I am writing a book based on Springer's svmono (http://resource-cms.springer.com/spring ... monographs) document class. So, according to your suggestion, it is not possible for me to use standard class like scrbook.

Ever since I started preparing my academic documents in LaTeX, I have been using BibTeX to produce bibliographies for all of my documents (thesis, papers, technical documents, etc.). And this way it used to generate the bibliography at the end of the document either in form of a chapter (in case of Thesis) or in form of a section (in case of paper). However, with my current assignment, I need to include the Reference section at the end of each chapter. I have a single ref.bib file which contains all of the references. Now I want to use that ref.bib and Springer's bibliography style file (spmpsci.bst) to generate separate reference section at the end of each chapter. Could you please help me out?

Thanks
SAMIRAN.

P.S. If required I shall create a different thread for this question.

User avatar
Johannes_B
Site Moderator
Posts: 3584
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Mon Oct 12, 2015 2:09 pm

A new thread will indeed be good, it is easier for others to find solutions using google.


A little remark: Springer has a quite strict layout, i think you are not allowed to add lines to the toc.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

User avatar
Stefan Kottwitz
Site Admin
Posts: 8529
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Mon Oct 12, 2015 3:01 pm

Hi Samiran,

sounds like chapterbib or bibunits would be good for that case.

Stefan
Site admin

samirandam
Posts: 7
Joined: Sat Oct 10, 2015 7:47 pm

Postby samirandam » Mon Oct 12, 2015 5:39 pm

Hi Stefan,

I have created a separate thread (viewtopic.php?f=44&t=26793). Could you please provide me a step-by-step guide. Actually I am not sure about the series of commands that have to executed in order to generate the PDF having chapter-wise reference list.


Hi Johannes,

Thank you for your suggestion. I didn't know it. I saw one of the books from Springer which has this type formatting in TOC which provide a very clear segregation between the different parts in ToC. So I thought of implementing the same in my write-up.

Thanks
Samiran.


Return to “Text Formatting”

Who is online

Users browsing this forum: Exabot [Bot] and 2 guests