Hot answers tagged

8

\renewcommand*\thechapter{\ifnum\value{chapter}<10 0\fi\arabic{chapter}}


5

It's not much different from things like \chapter{abc \eqref{def}} (\eqref is one of the few fragile commands). The macro \luaexec is fragile, so it should be protected; burying it into another command is not sufficient, unless the other command is protected. \documentclass{book} \usepackage{luacode} \newcommand\CalculusResult{% \luaexec{Calculus = 1/3 ...


4

Using \ifcase...\fi conditional in advance (requires the relevant chapter prefixes to be defined in advance, of course too!) \documentclass{book} \usepackage{tocloft} \addtolength{\cftchapnumwidth}{20pt} \addtolength{\cftsecnumwidth}{20pt} \renewcommand{\thechapter}{% \ifcase\value{chapter} \or LAW% \or VNR% \or FOO% \or FOOBAR% \or ...


4

It's certainly possible: \documentclass{book} \makeatletter \newcommand{\chapterkey}[1]{% \renewcommand{\chapter@key}{#1}% } \newcommand{\chapter@key}{???} % initialize \renewcommand{\thechapter}{\chapter@key} \makeatother \begin{document} \chapterkey{LAW} \chapter{foo} \section{Problems} \section{Solutions} \chapterkey{VNR} \chapter{bar} \section{...


4

As the OP notes in the comment, \lsstyle, while it works as an argument to titlesec, does not allow for the letterspacing value to be explicitly set. Here, I introduce \lsstylehelp{} in lieu of \lsstyle, where the argument is the letterspacing value to set for the subsequent \lsstyle. The definition is simply \newcommand\lsstylehelp[1]{\edef\MT@...


3

\frontmatter removes the \chapter numbering, so you'll have to use \mainmatter somewhere... either in introduzione.tex or capitolo1.tex. However, I'd place it inside your main TeX file since it aids in the visible document structure. \frontmatter is defined like this inside book.cls: \newcommand\frontmatter{% \cleardoublepage \@mainmatterfalse \...


3

Under the regular document class that have \chapters, you'll have to capture three possible arguments: *, as in \chapter*{<title>} Optional argument [..], as in \chapter[<toc>]{<title>} Mandatory argument {...}, as in \chapter{<title>}. Note that the above three arguments can be intermixed/used together, as in \chapter*[<toc>...


3

Just using \renewcommand{\chapter}{} would leave the moving arguments in the stream input, getting them typeset, e.g. \chapter{foo} would yield \chapter empty {foo} argument is no argument any longer, but a typeset text, i.e. foo would be printed. \chapter itself doesn't have arguments, but branches into \@chapter and \@schapter, depending on the version ...


2

Well, your question does not show an minimal working example, but I guess, that you use class article instead of report or book. Class article does not know \chapter, which causes error messages in the log file you should see. Change article to report or book, the the command \chapter can be used and the TOC contains also your used chapter headings ... ...


2

Your \mfc macro does not set any marks for the page header. So you have to add something like \markboth{\chaptermarkformat #2}{} after \refstepcounter{chapter}. Here is different suggestion that also works for chapter titles which are longer than one line. And it is also possible to use the optional argument for a short title in TOC and/or header. \...


2

I think, this is what you wanted: I've changed the code from another answer of mine (Chapter style for a book of complied articles) and reused it. \documentclass{book} \usepackage{xcolor} \usepackage{xkeyval} \usepackage{xparse} \usepackage{blindtext} \makeatletter \let\latex@chapter\chapter \def\latex@starttoc#1{% \begingroup \makeatletter \@...


2

You need an updated version of \@makechapterhead since the current one doesn't allow for the line breaks since it uses \centerline. Instead using \centering: \def\@makechapterhead#1{% % \vspace*{50\p@}% {\parindent \z@ \raggedright \normalfont \centering \ifnum \c@secnumdepth >\m@ne \large\bfseries \@chapapp\space \thechapter \...


2

Instead of a tabular, you could use a raster with an extruded right box. Following code needs some geometry adjustments, but can help as starting point. \documentclass{book} \usepackage{lipsum} \usepackage[most]{tcolorbox} \makeatletter \def\thickhrulefill{\leavevmode \leaders \hrule height 1ex \hfill \kern \z@} \def\@makechapterhead#1{% \reset@font ...


2

Just replace \titleformat with this: \titleformat {\chapter} [display] {\filcenter\normalfont\scshape\huge} {\HUGE\thechapter} {18pt} {\textsomels}[\vspace{42pt}]


2

As Christian Hupfer pointed out, the problem is that the sectional division Chapter is unknown. Probably you meant chapter: \documentclass[12pt,a4paper,oneside,openright]{book} %oneside versione segreteria \usepackage[english,italian]{babel} \usepackage[a4paper,top=2cm,bottom=2cm,left=3cm,right=2.5cm]{geometry} \usepackage[T1]{fontenc} \usepackage[utf8]{...


2

Here is a solution Notes The solution use (la)TeX loop. File names changed 1_1_1 -->1+1+1 (this is easier) \documentclass{article} \usepackage{lipsum} \setcounter{secnumdepth}{4} \newif\ifmoreinput \newcounter{sec} \newcounter{ssec}[sec] \newcounter{sssec}[ssec] \newcounter{parg}[sssec] \begin{document} \loop \stepcounter{section}% \stepcounter{sec}...


2

This approach may not be a good idea, LaTeX is designed to take care of the numbering for you (for example when you decide later to add a section between 1 and 2). If you want to do it anyway, a scripting language is probably the easiest way. Example in Perl: use File::Find; use Cwd; # get working directory for script $cwd1 = getcwd(); # find all tex ...


1

This is known problem because of starred chapters. Here are two ways: 1 (not recommended) Replace \setcounter{mtc}{9} with \setcounter{mtc}{6} (well try to find the correct value) 2 Remove \setcounter{mtc}{9} and redefine \addtotoc \renewcommand\addtotoc[1]{% \refstepcounter{dummy}% \addstarredchapter{#1}% or \mtcaddchapter[#1]% \markboth{#1}{}}


1

Try something like this to change the font only for the label: \usepackage{fmtcount} \usepackage{tahoma} \titleformat{\chapter}[display]{\filcenter}{\fontfamily{tahoma}\selectfont\MakeUppercase\chaptername~\ordinalstring{chapter}}{6ex}{}


1

A manual setup, not very convenient, by storing the chapter number and restoring it later on. (In this example, the chapter number width in the ToC should be increased, e.g. with \addtolength{\cftchapnumwidth}{5pt} from tocloft package) \documentclass{book} \newcounter{subchapterusage} \makeatletter \let\latex@@thechapter\thechapter \@addtoreset{...


1

It's better to associate the "random text" within the ToC as being some form of sectional unit. Just like you have chapter, section, ..., let's call it special: \documentclass[notoc]{tufte-book} \setcounter{secnumdepth}{3} \setcounter{tocdepth}{3} \makeatletter \newcommand{\l@special}[2]{#1\endgraf} \makeatother \begin{document} \tableofcontents \...


1

Counters only accept integers values, so try this: \setcounter{chapter}{2} \setcounter{section}{3} \section{Your Headline} % This is section 2.4 Or \setcounter{chapter}{2} \setcounter{section}{2} \section{Your Headline} % This is section 2.3


1

Warning: This will leave all chapter names in upper case characters. The spacing between Chapter Number 1 and Chapter Title is controlled in \@makechapterhead, there's a \vskip 20\p@, i.e. 20pt, being hardcoded. This can be changed by a patch, inserting some other length, which can be changed easily. Warning 2: times is a deprecated package. Use mathptmx ...


1

If you are using KOMA-Script version 3.17 or older you have to replace \include{...} by \clearpage\input{...}. If you do not want that the content of the loaded file starts on a new page then use only \input{...}. With KOMA-Script version 3.18 or newer there is no problem with the order of the TOC entries. But the code that removes the chapter heading does ...



Only top voted, non community-wiki answers of a minimum length are eligible