Ask for help : Package titlesec affects the settings of tocloft

Jilong Yin <[email protected]>
Newsgroups gmane.comp.tex.miktex
Message-ID <CAEd1eRU1J9cW=YqApDUkJ1poxE74SMLLhPD2u-w=VKfPjDisiQ@mail.gmail.com>
Hello, everyone.

 I am facing a problem when formatting my report edited by Latex.

I wanto to do the following two formatting

1.  to supress the line break after chapter title, for example
   Chapter 1 Exercise A
  to replace the default one
  Chapter 1
    Exercise  A

2. to append "Appendix x........#"' to TOC, replacing default "x........#"


I use package titlesec to do format 1 and use package tocloft to do format
2.
But I found the two package affect each other.
I can not get the two format at the same time.

Anyone can help me some, thanks in advance.

The following is the my minimal example.



\documentclass[a4paper,openany]{book}

\usepackage{tocloft}

\usepackage{titlesec}

\usepackage{nonumonpart}   %dont display page number on part cover page

%to append "Appendix x........#"' to TOC, replacing default "x........#"
\renewcommand{\partname}{Appendix}
\makeatletter
\@addtoreset{chapter}{part}
\makeatother
\newlength\mylen
\renewcommand\thepart{\Roman{part}}
\renewcommand\cftpartpresnum{\Large Appendix~}
\settowidth\mylen{\bfseries\cftpartpresnum\cftpartaftersnum}
\addtolength\cftpartnumwidth{\mylen}


%to supress the line break after chapter title
\titleformat{\chapter}% reformat chapter headings
    [hang]% like section, with number on same line
    {\Huge\bfseries}% formatting applied to whole
    {\thechapter}% Chapter number
    {0.5em}% space between # and title
    {}% formatting applied just to title
        %

\begin{document}

    \pagenumbering{roman}
    \tableofcontents

\pagenumbering{arabic}
\part{My homework1}
      \chapter{Exercise A}
              I am exercise A.
      \chapter{Exercise B}
              I am exercise B.

\part{My homework2}
      \chapter{Exercise A}
              I am exercise A.
      \chapter{Exercise B}
              I am exercise B.

\end{document}
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.