Text FormattingNo bold font in TOC (section names)

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
phini2006
Posts: 7
Joined: Sat Jan 09, 2010 1:13 pm

No bold font in TOC (section names)

Post by phini2006 »

Hi everyone,
I'm still new to LaTeX and have a question concerning the table of contents. I'm currently writing a thesis for my university degree and have to use a certain layout, which is only available as a Microsoft Word .dot.
At the moment I'm trying to make my thesis which is written in LaTeX look like that Word-based layout.

The only problem that remains is that the section names in the TOC are in bold font, but need to be "normal". How can I accomplish that?

Here is the beginning of my thesis:

Code: Select all

\documentclass[paper=a4, liststotocnumbered, bibtotocnumbered]{scrartcl}
        
\usepackage[utf8]{inputenc}

\usepackage{ngerman} %Deutsches Sprachpaket, inkl. neuer Rechtschreibung

\usepackage{graphicx} %Einbinden von Bildern

\usepackage[T1]{fontenc}

\usepackage{listings} %schönere Anzeige von Quellcode

\usepackage{textcomp}

\usepackage{fancyhdr} %Kopfzeilen gestalten

\usepackage[justification=raggedright,singlelinecheck=false]{caption} %Bildunterschriften linksbündig

\usepackage{helvet} %Helvetica als Standardschriftart
\renewcommand{\familydefault}{\sfdefault} %Helvetica als Standardschriftart

\setlength{\parindent}{0pt} %kein Einzug am Beginn eines Absatzes
\setlength{\parskip}{2ex plus0.3ex minus0.1ex} %Abstand zwischen 2 Absätzen

\pagestyle{fancy} %eigener Seitenstil
\fancyhf{} %alle Kopf- und Fußzeilenfelder bereinigen
\renewcommand{\headrulewidth}{0.4pt} %Kopfzeilen-Unterstrich einstellen
\renewcommand{\sectionmark}[1]{\markboth{\thesection{} #1}{}}
\fancyhead[L]{\leftmark} %Kopfzeile links
\fancyhead[C]{} %zentrierte Kopfzeile
\fancyhead[R]{\thepage} %Kopfzeile rechts

\renewcommand*\figurename{Abb.} %Abbildungsbezeichnungen ändern
\renewcommand{\thefigure}{\arabic{section}-\arabic{figure}} %Abbildungsbezeichnungen ändern
\makeatletter \@addtoreset{figure}{section} \makeatother %Abbildungsbezeichnungen ändern

\usepackage{setspace} %anderthalbfacher Zeilenabstand
\onehalfspacing %anderthalbfacher Zeilenabstand

\usepackage{geometry} %Seitenränder
\geometry{a4paper,left=30mm,right=20mm, top=30mm, bottom=25mm} %Seitenränder

\begin{document}
Thanks in advance
Philip
Last edited by phini2006 on Sun Jan 10, 2010 4:21 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

magicmoose
Posts: 90
Joined: Fri Nov 06, 2009 7:29 am

No bold font in TOC (section names)

Post by magicmoose »

Hi there,

I can't help with your specific problem but I will recommend the wordlike package, it may be able to help you mimic Word.

David
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

No bold font in TOC (section names)

Post by phi »

Hello,
you can redefine the font used for section entries in the TOC:

Code: Select all

\addtokomafont{sectionentry}{\mdseries}
Some suggestions:
  • Use the key–value interface for all class options, otherwise the class will switch to compatibility mode.
  • The scrartcl class is for articles that are generally no longer than 10 pages or so. For longer documents, use scrreprt or scrbook instead.
  • Use the babel package instead of the outdated ngerman package.
  • Load the lmodern package directly after fontenc, or make sure that the CM-Super fonts are installed, otherwise some pieces of text might use rasterized fonts instead of vector fonts.
  • Try to avoid packages like fancyhdr and caption if you can because KOMA-Script already provides similar functionality in many cases.
  • Never redefine the \parskip and \parindent parameters, use the parskip class option instead.
phini2006
Posts: 7
Joined: Sat Jan 09, 2010 1:13 pm

No bold font in TOC (section names)

Post by phini2006 »

Thanks for your help so far!

When I put the line

Code: Select all

\addtokomafont{sectionentry}{\mdseries}


directly above \begin{document} I get the following error:

Code: Select all

! Class scrreprt Error: font of element `sectionentry' can't be extended.

See the scrreprt class documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.43 \addtokomafont{sectionentry}{\mdseries}
Is it in the wrong place or what is my mistake?

I'll try to implement your other suggestions if there's enough time for it ;-)

Magicmoose: Thanks for suggesting the wordlike-package but I think I should have searched for it earlier, now it might be a bit late... As I said, it's just that one last small problem...

EDIT:
The additional help text for my error message is:
You've told me to extend the font selection of the element,
but either no such element is known by KOMA-Script
or the element does not use a special font selection
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

No bold font in TOC (section names)

Post by localghost »

phini2006 wrote:[...] When I put the line

Code: Select all

\addtokomafont{sectionentry}{\mdseries}

directly above \begin{document} I get the following error:

Code: Select all

! Class scrreprt Error: font of element `sectionentry' can't be extended.

See the scrreprt class documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.43 \addtokomafont{sectionentry}{\mdseries}
Is it in the wrong place or what is my mistake?
See Table 3.4 (p. 63f) in the KOMA Script manual for explanations.


Best regards and welcome to the board
Thorsten¹
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

No bold font in TOC (section names)

Post by phi »

phini2006 wrote:Thanks for your help so far!

When I put the line

Code: Select all

\addtokomafont{sectionentry}{\mdseries}


directly above \begin{document} I get the following error:

Code: Select all

! Class scrreprt Error: font of element `sectionentry' can't be extended.

See the scrreprt class documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.43 \addtokomafont{sectionentry}{\mdseries}
Is it in the wrong place or what is my mistake?
You never told us that you switched to the scrreprt class. As described in the manual, the sectionentry font exists only in the scrartcl class, and section entries are not bold by default in the scrreprt class anyway.
phini2006
Posts: 7
Joined: Sat Jan 09, 2010 1:13 pm

No bold font in TOC (section names)

Post by phini2006 »

Using the scrartcl-class I get the same error when using \addtokomafont{sectionentry}{\mdseries}:
! Class scrartcl Error: font of element `sectionentry' can't be extended.

See the scrartcl class documentation for explanation.
Type H <return> for immediate help.
...

l.44 \addtokomafont{sectionentry}{\mdseries}
Then I tried scrreprt-class and now the chapter-entries in the TOC are bold, which is just the same problem ;-)

I've decided to stick with the scrartcl-class for now, are there any more suggestions?

EDIT:
I've tried replacing \addtokomafont with \setkomafont, the result is almost the same:

Code: Select all

! Class scrartcl Error: font of element `sectionentry' can't be set.

See the scrartcl class documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.44 \setkomafont{sectionentry}{\mdseries}
                                          
? h
You've told me to redefine the font selection of the element,
but either no such element is known by KOMA-Script
or the element does not use a special font selection
Then I've taken a look at the komascript-manual where it clearly says that the scrartcl-class DOES have that option, what am I missing?
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

No bold font in TOC (section names)

Post by phi »

Here is an example.

Code: Select all

\documentclass[ngerman, version=last, paper=a4, toc=listofnumbered, toc=bibnumbered, parskip=full, captions=oneline, pagesize=auto]{scrreprt}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{blindtext}
\addtokomafont{chapterentry}{\mdseries}
\begin{document}
\tableofcontents
\blinddocument
\end{document}
phini2006
Posts: 7
Joined: Sat Jan 09, 2010 1:13 pm

No bold font in TOC (section names)

Post by phini2006 »

Thanks, but still the same problem:

Code: Select all

! Class scrreprt Error: font of element `chapterentry' can't be extended.

See the scrreprt class documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.44 \addtokomafont{chapterentry}{\mdseries}
                                            
? h
You've told me to extend the font selection of the element,
but either no such element is known by KOMA-Script
or the element does not use a special font selection
EDIT:
I tried it using just your minimal example, same problem!
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

No bold font in TOC (section names)

Post by localghost »

Take the example that phi provided, add the \listfiles command as very first line and start a new run.

Code: Select all

\listfiles
\documentclass[
  ngerman,
  version=last,
  paper=a4,
  toc=listofnumbered,
  toc=bibnumbered,
  parskip=full,
  captions=oneline,
  pagesize=auto
]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage{selinput}
\SelectInputMappings{%
  adieresis={ä},
  germandbls={ß},
  Euro={€}
}
\usepackage{babel}
\usepackage{lmodern}
\usepackage{blindtext}

\setkomafont{chapterentry}{\mdseries}

\begin{document}
  \tableofcontents
  \blinddocument
\end{document}
Search the log file for the list of used files and post the section between *File List* and *********** in your next reply. Here is my list.

Code: Select all

 *File List*
scrreprt.cls    2009/07/24 v3.04a KOMA-Script document class (report)
scrkbase.sty    2009/07/24 v3.04a KOMA-Script package (KOMA-Script-dependent ba
sics and keyval usage)
 scrbase.sty    2009/07/24 v3.04a KOMA-Script package (KOMA-Script-independent 
basics and keyval usage)
  keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
scrlfile.sty    2009/03/25 v3.03 KOMA-Script package (loading files)
tocbasic.sty    2009/06/08 v3.03b KOMA-Script package (handling toc-files)
scrsize11pt.clo    2009/07/24 v3.04a KOMA-Script font size class option (11pt)
typearea.sty    2009/07/24 v3.04a KOMA-Script package (type area)
 fontenc.sty
   t1enc.def    2005/09/27 v1.99g Standard LaTeX file
selinput.sty    2007/09/09 v1.2 Select input encoding (HO)
inputenc.sty    2008/03/30 v1.1d Input encoding file
kvsetkeys.sty    2009/07/30 v1.5 Key value parser with default handler support 
(HO)
infwarerr.sty    2007/09/09 v1.2 Providing info/warning/message (HO)
etexcmds.sty    2007/12/12 v1.2 Prefix for e-TeX command names (HO)
stringenc.sty    2008/10/27 v1.6 Converts strings between encodings (HO)
pdfescape.sty    2007/11/11 v1.8 Provides hex, PDF name and string conversions 
(HO)
pdftexcmds.sty    2009/09/23 v0.6 LuaTeX support for pdfTeX utility functions (
HO)
ifluatex.sty    2009/04/17 v1.2 Provides the ifluatex switch (HO)
 ltxcmds.sty    2009/08/05 v1.0 Some LaTeX kernel commands for general use (HO)

kvoptions.sty    2009/08/13 v3.4 Keyval support for LaTeX options (HO)
 ix-name.def    2009/08/13 v1.4 Name list (inputenx)
 se-utf8.def    2008/10/27 v1.6 stringenc: UTF-8
    utf8.def    2008/04/05 v1.1m UTF-8 support for inputenc
   t1enc.dfu    2008/04/05 v1.1m UTF-8 support for inputenc
  ot1enc.dfu    2008/04/05 v1.1m UTF-8 support for inputenc
  omsenc.dfu    2008/04/05 v1.1m UTF-8 support for inputenc
   babel.sty    2008/07/06 v3.8l The Babel package
ngermanb.ldf    2008/07/06 v2.6n new German support from the babel system
 lmodern.sty    2009/10/30 v1.6 Latin Modern Fonts
blindtext.sty    2009/06/14 V1.9b blindtext-Package
  xspace.sty    2006/05/08 v1.12 Space after command names (DPC,MH)
   t1lmr.fd    2009/10/30 v1.6 Font defs for Latin Modern
  t1lmss.fd    2009/10/30 v1.6 Font defs for Latin Modern
  ot1lmr.fd    2009/10/30 v1.6 Font defs for Latin Modern
  omllmm.fd    2009/10/30 v1.6 Font defs for Latin Modern
 omslmsy.fd    2009/10/30 v1.6 Font defs for Latin Modern
 omxlmex.fd    2009/10/30 v1.6 Font defs for Latin Modern
  omslmr.fd    2009/10/30 v1.6 Font defs for Latin Modern
 ***********
Post Reply