0

It took me a while to locate the error, but here's a MWE. I am using my own class, provided below:

 \documentclass[fleqn,10pt,twocolumn]{MWEclass}
 \usepackage{lipsum} % Required to insert dummy text
 \definecolor{pt_Blau_04}{RGB}{20,20,20}

   \begin{document}
    \makeatletter 
         \renewcommand\chapter{\global\@topnum\z@
                 \@afterindentfalse
                 \secdef\@chapter\@schapter}
    \def\@topnewpage[#1]{#1}
 \makeatother

 \input{MWEchapter}
 \chapter{Something}
 \lipsum[7-10]
 %\input{MWEchapter2}
 %\input{MWEchapter3}
  \end{document}

and the class:

 \NeedsTeXFormat{LaTeX2e}
 \ProvidesClass{MWEclass}[17/06/2013, v1.0]

 \AtEndOfClass{\RequirePackage{microtype}}
 \DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}}
 \ProcessOptions*
 \LoadClass{report}
 \RequirePackage[usenames,dvipsnames,svgnames,table]{xcolor}


 \RequirePackage[explicit]{titlesec}
 \newlength\mylena
 \newlength\mylenb
 \setlength\mylena{1.3cm}
 \setlength\mylenb{\dimexpr\columnwidth-\mylena\relax}

 \newcommand\PlaceNumber[1]{%
   \makebox[\mylena][l]{#1}}

 \titleformat{\chapter}
  {\color{pt_Blau_04}\Large\sffamily\bfseries}
  {}
  {0em}
  {\PlaceNumber{\thechapter}\parbox[t]{\mylenb}{\raggedright#1}}

 \titlespacing*{\chapter}{0pc}{3ex \@plus4pt \@minus3pt}{5pt}

If i want to avoid the pagebreak for every new chapter (The chapters MWEchapter are just lipsum text) it works up to including TWO chapters, if I want to include more, theres an error message about horizontal mode and the titlesec package..

  • If you don't want chapters to start a new page, why do you base your document class on book, rather than report? – mafp Jun 24 '13 at 10:52
  • the same happens if i use report.. i guess its because of the twocolumn thing – Kathiieee Jun 24 '13 at 12:28
  • I just checked with a twocolumn book together with your code snippet, and it does not break pages at new chapters. So please provide a complete minimal working example (MWE) that let us reproduce the problem. – mafp Jun 24 '13 at 16:15
  • Done, the problem is including more than two chapters.. but how can i fix that.. – Kathiieee Jun 27 '13 at 19:47
  • I tried the updated MWE, and again, no page breaks. Please test your MWE before posting it. – mafp Jun 27 '13 at 22:32
1

The error stems from the fact that your redefinition of \chapter does not make sure that a paragraph is ended when the chapter title is about to be typeset. So something like

Text\chapter{Foo}

triggers the error.

Since you are using titlesec anyway, I would recommend to remove the hacky redefinition of \chapter, and use the interface of titlesec to make chapters not start a new page. This can be achieved by setting the class of \chapters from top to straight. MWEclass.cls then looks like this (see the last line):

\NeedsTeXFormat{LaTeX2e}
 \ProvidesClass{MWEclass}[17/06/2013, v1.0]

 \AtEndOfClass{\RequirePackage{microtype}}
 \DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}}
 \ProcessOptions*
 \LoadClass{report}
 \RequirePackage[usenames,dvipsnames,svgnames,table]{xcolor}

 \RequirePackage[explicit]{titlesec}
 \newlength\mylena
 \newlength\mylenb
 \setlength\mylena{1.3cm}
 \setlength\mylenb{\dimexpr\columnwidth-\mylena\relax}

 \newcommand\PlaceNumber[1]{%
   \makebox[\mylena][l]{#1}}

 \titleformat{\chapter}
  {\color{pt_Blau_04}\Large\sffamily\bfseries}
  {}
  {0em}
  {\PlaceNumber{\thechapter}\parbox[t]{\mylenb}{\raggedright#1}}

 \titlespacing*{\chapter}{0pc}{3ex \@plus4pt \@minus3pt}{5pt}

\titleclass{\chapter}{straight}%% added

and the redefinition of \chapter in your main file can be deleted.

0

This works for me, only the cleardoublepage needs to be reset, if you hold it in memory, it can be restored.

\documentclass{book}

\begin{document}
\chapter{One}
Bla
\chapter{Two}
Bla Bla

%Reset
\makeatletter
    \let\cleardoublepage@old\cleardoublepage
    \let\cleardoublepage\relax
\makeatother

\chapter{Three}
Bla Bla Bla

%Restore
\makeatletter
    \let\cleardoublepage\cleardoublepage@old
\makeatother

\chapter{Four}
Bla Bla Bla

\end{document}
  • That doesnt work in twocolumn documents. it says "Float(s) lost" – Kathiieee Jun 24 '13 at 9:09
  • I don't know in that case. – Nicholas Hamilton Jun 24 '13 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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