GeneralHyphen replaced in ToC Entries

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
nvx
Posts: 25
Joined: Mon Dec 17, 2007 7:49 pm

Hyphen replaced in ToC Entries

Post by nvx »

Has anyone here ever encountered

Code: Select all

\unhbox \voidb@x \kern \z@ \char `\discretionary {-}{}{}
being put into a .toc file instead of a hyphen? This causes the respective ToC entry to be typeset with a zero instead of a hyphen. Frankly, I cannot understand why this is happening, because other (sub)section headers containing hyphens are typeset as they should...


Thanks for any advice,
nvx

Recommended reading 2024:

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

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

User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Hyphen replaced in ToC Entries

Post by Stefan Kottwitz »

If your hyphen is a fragile macro, use \protect when you write it to the .toc file.

Stefan
LaTeX.org admin
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Hyphen replaced in ToC Entries

Post by cgnieder »

nvx wrote:Frankly, I cannot understand why this is happening, because other (sub)section headers containing hyphens are typeset as they should...
Then you should post a Infominimal working example that shows the problem (only if Stefan's proposal doesn't help you). How do you insert the hyphen?

Regards
site moderator & package author
nvx
Posts: 25
Joined: Mon Dec 17, 2007 7:49 pm

Hyphen replaced in ToC Entries

Post by nvx »

Dear Stefan,

thanks for such a prompt response. I had no idea that there is something called 'fragile macro' or that a hyphen can be a macro by itself. Nevertheless, placing \protect before the hyphen worked like a charm.
cgnieder wrote:How do you insert the hyphen?
Stefan's suggestion was dead-on, but thanks anyway. :) As for the hyphen, I inserted it in the regular manner: a single hyphen character (dash) - no double- or triple-dashes or special characters (en-dash, em-dash, ...).


nvx
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Hyphen replaced in ToC Entries

Post by cgnieder »

Hmm... seems that some package or the class you're using is making - an active character and defined it in a fragile way.
site moderator & package author
Post Reply