Thread: [MiKTeX] Ask for help : Package titlesec affects the settings of tocloft
MiKTeX source code moved to GitHub
Brought to you by:
csc
From: Jilong Y. <yin...@gm...> - 2014-04-14 08:53:00
|
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} |
From: Vladimir Y. <yum...@ma...> - 2014-04-14 20:06:09
|
You may re-define any commands by \renewcommand{} See examples in texmf\tex\latex\base\article.cls and similar and understand how it works. Command definitions often use @ character, so they must be put between \setatletter and \setatother brackets. Mon, 14 Apr 2014 17:52:53 +0900 от Jilong Yin <yin...@gm...>: >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 >_______________________________________________ >MiKTeX-Users mailing list >MiK...@li... >https://lists.sourceforge.net/lists/listinfo/miktex-users |
From: Vladimir Y. <yum...@ma...> - 2014-04-14 20:12:36
|
Sorry, \makeatletter and \makeatother brackets Mon, 14 Apr 2014 17:52:53 +0900 от Jilong Yin <yin...@gm...>: >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 >_______________________________________________ >MiKTeX-Users mailing list >MiK...@li... >https://lists.sourceforge.net/lists/listinfo/miktex-users |
From: Pétiard F. <pet...@fr...> - 2014-04-15 04:48:07
|
Le 14/04/2014 10:52, Jilong Yin a écrit : > 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. Hello Package tocloft tests if titlesec is loaded. A solution: put after \begin{document} (and before \tableofcontents): \makeatletter \@cfttitlesecfalse \makeatother François |
From: Jilong Y. <yin...@gm...> - 2014-04-15 09:48:45
|
Thanks for your help, François. I will try it. After I posted the question, I digged Internet more, and found another package titletoc can also format the TOC and can be used with titlesec package well. Thank you . The following is my code to do this . \titlecontents{part}% <section-type> [0pt]% <left> {\bfseries}% <above-code> {}% <numbered-entry-format> {\addvspace{1cm}\\ \Large \partname~}% <numberless-entry-format> {\hfill\contentspage}% <filler-page-format> \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 2014-04-15 13:28 GMT+09:00 Pétiard François <pet...@fr...>: > Le 14/04/2014 10:52, Jilong Yin a écrit : > > 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. > > Hello > > Package tocloft tests if titlesec is loaded. > A solution: > put after \begin{document} (and before \tableofcontents): > > \makeatletter > \@cfttitlesecfalse > \makeatother > > François > > > > ------------------------------------------------------------------------------ > 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 > _______________________________________________ > MiKTeX-Users mailing list > MiK...@li... > https://lists.sourceforge.net/lists/listinfo/miktex-users > |