Legrand 橙皮书模板:无法拆分章节标题

Legrand 橙皮书模板:无法拆分章节标题

章节标题很长,我无法将其拆分。我尝试过使用 \ 或在 stackexchange 上找到的其他技巧,但徒劳无功。

\documentclass[12pt]{book}
\usepackage[paperwidth=20cm, paperheight=29cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{pifont} %Sutilise avec \usepackage{amsmath} pour la commande \text{\ding{113}}  \Delta
\usepackage{adjustbox}
\usepackage[activate={true,nocompatibility},final,tracking=true,kerning=true,spacing=true,factor=1100,stretch=10,shrink=10]{microtype}
\usepackage{multicol}
\usepackage{mathtools}
\usepackage{makecell}
\usepackage{tabularx}
\usepackage{listings}
\usepackage{ragged2e}
\newcolumntype{R}{>{\RaggedLeft}X}

\usepackage[shortlabels]{enumitem} % Pour \begin{enumerate}a)
\usepackage{xcolor}
\usepackage{hyperref}
\usepackage{caption}
\usepackage{paracol} %Permet de diviser la page en 2 colonnes
\usepackage{titlesec} %Pour modifier le fomat du titre de section subparagraph
\usepackage{cancel} %Pour écrire chiffres barrés
\usepackage{afterpage}

\titleformat*{\subparagraph}{\bfseries\itshape} %Modification du fomat du titre de section subparagraph

\newcolumntype{L}[1]{>{\RaggedRight}X} % new

\usepackage{pdflscape} % for 'landscape' env.
\usepackage{booktabs}  % for well-spaced horizontal rules
\usepackage{xurl}      % for '\path' macro, allow line breaks at arbitrary points
\usepackage{fvextra}

\input{structure.tex} % Insert the commands.tex file which contains the majority of the structure behind the template

\hypersetup{pdftitle={Title},pdfauthor={Author}} % Uncomment and fill out to include PDF metadata for the author and title of the book

% Définition du caractère point de grosse taille bigcdot
\makeatletter
\newcommand*\bigcdot{\mathpalette\bigcdot@{1}}
\newcommand*\bigcdot@[2]{\mathbin{\vcenter{\hbox{\scalebox{#2}{$\m@th#1\bullet$}}}}}
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%% Eviter les fractures de mots avec traits d'union %%%%%%%%%%%%%%%

\tolerance=1
\emergencystretch=\maxdimen
\hyphenpenalty=10000
\hbadness=10000

\begin{document}

\chapterimage{1.pdf} % Table of contents heading image

\chapter{Langages récursivement énumérables\index{Récursivement énumérables}} \label{chap:turing}

\end{document}

以下是structure.tex文件内容

\usepackage{graphicx} % Required for including pictures
\graphicspath{{Pictures/}} % Specifies the directory where pictures are stored

\usepackage{pstricks}  %%
\usepackage{tikz}  %%
\usetikzlibrary{arrows.meta, calc, chains, positioning, babel}

\usepackage{tikz-qtree}

%\usepackage{pst-all}  %%
\usepackage{amsmath}  %%

\usepackage{amssymb}
\usepackage{multirow}
%\setlength{\unitlength}{1cm}

\usepackage[french]{babel} % English language/hyphenation

\usepackage{enumitem} % Customize lists
\setlist{nolistsep} % Reduce spacing between bullet points and numbered lists

\usepackage{booktabs} % Required for nicer horizontal rules in tables

\usepackage{xcolor} % Required for specifying colors by name

\usepackage{picture}

\definecolor{ocre}{RGB}{70,50,212} % Define the orange color used for highlighting throughout the book

\usetikzlibrary{arrows.meta,arrows,chains,automata,shapes,matrix,positioning,scopes,calc}

\usepackage{float}
\usepackage{avant} % Use the Avantgarde font for headings
\usepackage{mathptmx} % Use the Adobe Times Roman as the default text font together with math symbols from the Sym­bol, Chancery and Com­puter Modern fonts
\usepackage{microtype} % Slightly tweak font spacing for aesthetics
\usepackage[utf8]{inputenc} % Required for including letters with accents
\usepackage[T1]{fontenc} % Use 8-bit encoding that has 256 glyphs
\usepackage[style=numeric,citestyle=numeric,sorting=nyt,sortcites=true,autopunct=true,babel=hyphen,hyperref=true,abbreviate=false,backref=true,backend=biber]{biblatex}
\usepackage{titletoc} % Required for manipulating the table of contents

%----------------------------------------------------------------------------------------
%   SECTION NUMBERING IN THE MARGIN
%----------------------------------------------------------------------------------------

\makeatletter
\renewcommand{\@seccntformat}[1]{\llap{\textcolor{ocre}{\csname the#1\endcsname}\hspace{1em}}}                    
\renewcommand{\section}{\@startsection{section}{1}{\z@}
{-4ex \@plus -1ex \@minus -.4ex}
{1ex \@plus.2ex }
{\normalfont\large\sffamily\bfseries}}
\renewcommand{\subsection}{\@startsection {subsection}{2}{\z@}
{-3ex \@plus -0.1ex \@minus -.4ex}
{0.5ex \@plus.2ex }
{\normalfont\sffamily\bfseries}}
\renewcommand{\subsubsection}{\@startsection {subsubsection}{3}{\z@}
{-2ex \@plus -0.1ex \@minus -.2ex}
{.2ex \@plus.2ex }
{\normalfont\small\sffamily\bfseries}}                        
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}
{-2ex \@plus-.2ex \@minus .2ex}
{.1ex}
{\normalfont\small\sffamily\bfseries}}

%----------------------------------------------------------------------------------------
%   CHAPTER HEADINGS
%----------------------------------------------------------------------------------------

% A switch to conditionally include a picture, implemented by Christian Hupfer
\newif\ifusechapterimage
\usechapterimagetrue
\newcommand{\thechapterimage}{}%
\newcommand{\chapterimage}[1]{\ifusechapterimage\renewcommand{\thechapterimage}{#1}\fi}%
\newcommand{\autodot}{.}
\def\@makechapterhead#1{%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west,inner sep=0pt] at (0,0) {\ifusechapterimage\includegraphics[width=\paperwidth]{\thechapterimage}\fi};
\draw[anchor=west] (\Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]{\strut\makebox[22cm]{}};
\draw[anchor=west] (\Gm@lmargin+.3cm,-9cm) node {\huge\sffamily\bfseries\color{black}\thechapter\autodot~#1\strut};
\end{tikzpicture}};
\end{tikzpicture}
\else
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west,inner sep=0pt] at (0,0) {\ifusechapterimage\includegraphics[width=\paperwidth]{\thechapterimage}\fi};
\draw[anchor=west] (\Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]{\strut\makebox[22cm]{}};
\draw[anchor=west] (\Gm@lmargin+.3cm,-9cm) node {\huge\sffamily\bfseries\color{black}#1\strut};
\end{tikzpicture}};
\end{tikzpicture}
\fi\fi\par\vspace*{270\p@}}}

%-------------------------------------------

\def\@makeschapterhead#1{%
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west,inner sep=0pt] at (0,0) {\ifusechapterimage\includegraphics[width=\paperwidth]{\thechapterimage}\fi};
\draw[anchor=west] (\Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]{\strut\makebox[22cm]{}};
\draw[anchor=west] (\Gm@lmargin+.3cm,-9cm) node {\huge\sffamily\bfseries\color{black}#1\strut};
\end{tikzpicture}};
\end{tikzpicture}
\par\vspace*{270\p@}}
\makeatother

感谢您的任何帮助。

答案1

您可以发布的更合理的例子是

\documentclass[12pt]{book}
\usepackage[paperwidth=20cm, paperheight=29cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{tikz}  %%
\usetikzlibrary{arrows.meta, calc, chains, positioning, babel}
\definecolor{ocre}{RGB}{70,50,212} %
\makeatletter
\newif\ifusechapterimage
\newcommand{\autodot}{.}
\def\@makechapterhead#1{%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west,inner sep=0pt] at (0,0) {\ifusechapterimage\includegraphics[width=\paperwidth]{\thechapterimage}\fi};
\draw[anchor=west] (\Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]{\strut\makebox[22cm]{}};
\draw[anchor=west] (\Gm@lmargin+.3cm,-9cm) node {\huge\sffamily\bfseries\color{black}\thechapter\autodot~#1\strut};
\end{tikzpicture}};
\end{tikzpicture}% avoid nesting tikzpicture!!!!!!
\else
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west,inner sep=0pt] at (0,0) {\ifusechapterimage\includegraphics[width=\paperwidth]{\thechapterimage}\fi};
\draw[anchor=west] (\Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]{\strut\makebox[22cm]{}};
\draw[anchor=west] (\Gm@lmargin+.3cm,-9cm) node {\huge\sffamily\bfseries\color{black}#1\strut};
\end{tikzpicture}};
\end{tikzpicture}% avoid nesting tikzpicture!!!!!!
\fi\fi\par\vspace*{270\p@}}}

\makeatother



\begin{document}
\chapter{Langages récursivement énumérables\index{Récursivement énumérables}} \label{chap:turing}
\end{document}

生产

在此处输入图片描述

tikz 节点是不可破坏的 mbox,除非您指定宽度或嵌套 parbox。我在这里使用 parbox,并将其移动到绘制椭圆的节点内,以便椭圆可以扩展以容纳额外的线条。

\documentclass[12pt]{book}
\usepackage[paperwidth=20cm, paperheight=29cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{tikz}  %%
\usetikzlibrary{arrows.meta, calc, chains, positioning, babel}
\definecolor{ocre}{RGB}{70,50,212} %
\makeatletter
\newif\ifusechapterimage
\newcommand{\autodot}{.}
\def\@makechapterhead#1{%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west,inner sep=0pt] at (0,0) {\ifusechapterimage\includegraphics[width=\paperwidth]{\thechapterimage}\fi};
\draw[anchor=west] (\Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,
%fill opacity=0.5,
inner sep=15pt]{%
  \huge\sffamily\bfseries\color{black}\strut\thechapter\autodot~%
  \parbox[t]{14cm}{\raggedright#1\strut}};
%\draw[anchor=west] (\Gm@lmargin+.3cm,-9cm) node {}};
\end{tikzpicture}};
\end{tikzpicture}% avoid nesting tikzpicture!!!!!!
\else
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west,inner sep=0pt] at (0,0) {\ifusechapterimage\includegraphics[width=\paperwidth]{\thechapterimage}\fi};
\draw[anchor=west] (\Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]{\strut\makebox[22cm]{}};
\draw[anchor=west] (\Gm@lmargin+.3cm,-9cm) node {\huge\sffamily\bfseries\color{black}#1\strut};
\end{tikzpicture}};
\end{tikzpicture}% avoid nesting tikzpicture!!!!!!
\fi\fi\par\vspace*{270\p@}}}

\makeatother



\begin{document}
\chapter{Langages récursivement énumérables\index{Récursivement énumérables}} \label{chap:turing}
\end{document}

在此处输入图片描述

相关内容