Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there a way to completely hide the \part and \chapter headings when they are called (but still show them in the toc)? Maybe using titlesec?

Note:

I'm using something like this to capture the chapter headings and reuse them:

\documentclass{book}
\usepackage[explicit]{titlesec}
\usepackage{lipsum}

% Define \chaphead to be used in section headings
\let\oldchapter\chapter
\newcommand\temphead{}
\newcommand\chaphead{}
\renewcommand\chapter[2][\temphead]{%
    \renewcommand\temphead{#2}%
    \renewcommand\chaphead{#2}%
    \oldchapter[#1]{#2}}

\newcommand*\Hide{%

\titleformat{\chapter}[display]
  {}{}{0pt}{}
%\titleclass{\chapter}{straight}

\titleformat{\section}[display]
  {\large} % format
  {\chaphead, section \thesection} % label
  {10pt} %sep
  {} %before
}

\begin{document}

{
\Hide
\chapter{A first chapter}
\section{A first section}
\lipsum
}

\chapter{A second chapter}
\section{A second section}
\lipsum

\end{document}

When activating \titleclass{\chapter}{straight}, it seems \chaphead is not capture anymore.

share|improve this question
    
The headings must not be typeset, but the space they occupied must remain? –  Gonzalo Medina Apr 18 '11 at 12:20
    
I mean to hide the chapter name completely, so it doesn't appear in the text. –  ℝaphink Apr 18 '11 at 12:49
add comment

1 Answer

up vote 3 down vote accepted

Indeed, you can use the titlesec package; its explicit option allows you to remove the titles:

\documentclass{book}
\usepackage[explicit]{titlesec}

\newcommand*\Hide{%
\titleformat{\chapter}[display]
  {}{}{0pt}{\Huge}
\titleformat{\part}
  {}{}{0pt}{}
}

\begin{document}
\tableofcontents

{
\Hide
\part{A test part}
\chapter{A test chapter}
\section{Test section}
}

\part{A test part}
\chapter{A test chapter}
\section{Test section}

\end{document}
share|improve this answer
    
Alright, that removes the chapter headings... but it also removes the section headings, and the chapter headings outside of the environment in which I did the call to \titleformat... –  ℝaphink Apr 18 '11 at 14:06
    
You can keep the changes local by using the grouping mechanism; I've edited my example to reflect this approach (and defining a command to simplify the work). –  Gonzalo Medina Apr 18 '11 at 14:11
    
Hmmm... I'm using an environment already, that should limit the scope, shouldn't it? –  ℝaphink Apr 18 '11 at 14:15
    
Without your actual relevant code it's really hard to tell. Why don't you add to your question all the necessary elements (in the sense of a minimal working example) affecting your request? –  Gonzalo Medina Apr 18 '11 at 14:22
1  
Again, without knowledge of your actual relevant code, this process of guessing is totally useless and time wasting... as I already suggested, add a minimal working example of your relevant code. –  Gonzalo Medina Apr 18 '11 at 14:43
show 7 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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