如何换行部分?

如何换行部分?

我想包装该部分。我该怎么做?

在此处输入图片描述

以下代码是我的MWE。

\documentclass[b5paper,10pt,twoside,parskip=half,numbers=noenddot,bibliography=totoc]{scrbook}
%bibliography=totocnumbered numera la bibliografia

\newcommand{\Aref}[1]{Appendix  \ref{#1}} %\thechapter
\def\chapterautorefname{Chapter}
\usepackage{xspace}

%\usepackage[cam,a4,center,pdftex]{crop} %for markings
\usepackage[squaren]{SIunits} % provide \micro command
\usepackage{amsmath,amssymb}             % AMS Math
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{units} % nicefrac
\usepackage[italian]{babel} %modifica cesare
\usepackage{eurosym}
\usepackage{booktabs}
%\usepackage{csquotes}
%\usepackage[protrusion=true,expansion]{microtype}backend=biber,
%\usepackage[style=numeric-comp,citestyle=numeric-comp,bibstyle=numeric-short,sorting=none,natbib=true,backref=true,hyperref=true,autocite=superscript,maxnames=99,maxcitenames=2,isbn=false,url=false,eprint=false,firstinits=true,mcite,subentry]{biblatex}
%\usepackage[final]{microtype}
%\usepackage[superscript]{cite}%modifica cesare
\usepackage{microtype}
\usepackage{enumerate}
\usepackage{graphicx}
\usepackage{subfig}
%\usepackage[danish]{babel}
\usepackage{latexsym,amssymb,amsmath,verbatim}
\usepackage{array,booktabs}
\usepackage{placeins}
 \let\oldsection=\section % gemmer den gamle definition
 \renewcommand\section{\FloatBarrier\oldsection}
\usepackage{caption}
 \captionsetup{font=small,labelfont=bf}
%\usepackage{cite}
%\usepackage{hyperref}

%\DeclareFieldFormat{volcitevolume}{\bibstring{volume}\ppspace\RN{#1}}
%\AtEveryCitekey{\clearfield{institude}}
%\renewcommand{\cite}{\supercite}
%\renewcommand{\citep}{\supercite}
%\renewcommand{\citet}[2][]{\citeauthor{#2}\supercite{#2}\ifstrempty{#1}{}{, #1}}
% \DeclareFieldFormat{bibentrysetcount}{\newline(\mknumalph{#1})\addhighpenspace}
\usepackage{makeidx}
\usepackage{longtable}
\usepackage{calc}
%\usepackage{etoolbox}
\usepackage{leftidx}
\makeindex

\usepackage{booktabs}
\setlength{\heavyrulewidth}{1.2pt}
\usepackage{pdfpages}
\usepackage[left=3.15cm,right=2.55cm,top=1.8cm,bottom=0.89cm,includefoot,includehead,headheight=13.6pt]{geometry}
\usepackage{setspace}
\setstretch{1.1}
\usepackage[nottoc, notlof, notlot]{tocbibind}
\usepackage[nohints]{minitoc}
\setcounter{minitocdepth}{2}


\mtcindent=15pt
\renewcommand{\ptcfont}{\small\rm}
\renewcommand{\ptcCfont}{\small\bm}
\renewcommand{\ptcSfont}{\small\rm}
\renewcommand{\ptcSSfont}{\footnotesize\rm}
\renewcommand{\ptcSSSfont}{\footnotesize\rm}
% Use \minitoc where to put a table of contents
%\usepackage{cm-super}
\RequirePackage{fix-cm}

\usepackage{type1cm}
\usepackage{titlesec}

\usepackage{aecompl}
\usepackage{xargs}
% Glossary / list of abbreviations

\usepackage[intoc]{nomencl}
\renewcommand{\nomname}{List of Abbreviations}
%makeindex Thesis.nlo -o Thesis.nls

\makenomenclature
\usepackage{pgf}%,pgfarrows,pgfnodes,pgfautomata,pgfheaps,pgfshade}
\usepackage{tikz}
\usetikzlibrary{calc,decorations,decorations.pathmorphing,arrows,matrix,positioning,patterns}
\usepackage[version=3]{mhchem}% use \ce for chemistry
\usepackage{array}

% My pdf code


\usepackage{graphicx}
\DeclareGraphicsExtensions{.jpg}
\DeclareGraphicsExtensions{.pdf}

\graphicspath{{.}{images/}}

% Links in pdf
\usepackage{xcolor}
\selectcolormodel{cmyk}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{2}

% Some useful commands and shortcut for maths:  partial derivative and stuff

\newcommand{\pd}[2]{\frac{\partial #1}{\partial #2}}
\def\abs{\operatorname{abs}}
\def\argmax{\operatornamewithlimits{arg\,max}}
\def\argmin{\operatornamewithlimits{arg\,min}}
\def\diag{\operatorname{Diag}}
\newcommand{\eqRef}[1]{(\ref{#1})}

\titlespacing*{\chapter}{0cm}{-1.cm}{-40pt}%pbk
%\titleformat{\chapter}[display]{\Huge\filleft\scshape}{ \normalfont\bf\fontfamily{put}\fontseries{b}\fontsize{95pt}{0pt}\selectfont\thechapter}{20pt}{}[\titlerule\vspace{2ex}\filright\vspace{2ex}]

%\titleformat{\section}[block]
%{\normalfont\sffamily}
%{\thesection}{.5em}{\titlerule\\[.8ex]\bfseries}


\titlespacing*{\part}{-10pt}{120pt}{-80pt}%pbk
\titleformat{\part}[frame]{\Huge\filcenter\scshape}{ \normalfont\bf\fontsize{85pt}{0pt}\selectfont \raisebox{1.7cm}{ Part\fontfamily{put}\fontseries{b}\fontsize{105pt}{0pt}\selectfont \hspace{.2em}\thepart} }{30pt}{}[\filright]

 \newcommand\boxedSection[3]{{%
%
     \begin{tikzpicture}[inner sep=#3,line width=1.0pt]
         \node[anchor=east,rectangle,draw] at (0,0) (counter) {\textbf{#2}};
             \draw (counter.south west)  ++(.0pt,.5pt)-- ++($(\linewidth,0) - (2.5pt,0)$);
\node [right of=counter,anchor=west]{#1};
     \end{tikzpicture}
 }}
 \newcommand\boxedSectionB[3]{{%
%
     \begin{tikzpicture}[inner sep=#3,line width=1pt]
         \node[anchor=east,rectangle,draw,fill=black] at (0,0) (counter) {\color{white}\textbf{#2}};
             \draw (counter.south west) ++(.0pt,.5pt)-- ++($(\linewidth,0) - (2.5pt,0)$);
\node [right of=counter,anchor=west]{#1};
     \end{tikzpicture}
 }}
\newcommand\boxedsection[1]{\boxedSectionB{#1}{\thesection}{2mm}}
\newcommand\boxedsubsection[1]{\boxedSection{#1}{\thesubsection}{1.7mm}}
\newcommand\boxedsubsubsection[1]{\boxedSection{#1}{\thesubsubsection}{1.5mm}}
 \titleformat{\section}[hang]%
     {\usekomafont{section}}%
     {}%
     {.0em}%
     {\filright\boxedsection}%

 \titleformat{\subsection}[hang]%
     {\usekomafont{subsection}}%
     {}%
     {.0em}%
     {\filright\boxedsubsection}%
 \titleformat{\subsubsection}[hang]%
     {\usekomafont{subsubsection}}%
     {}%
     {.0em}%
     {\filright\boxedsubsubsection}%




\usepackage{rotating}
\usepackage{fancyhdr}                    % Fancy Header and Footer

% \usepackage{txfonts}                     % Public Times New Roman text & math font

%%% Fancy Header %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Fancy Header Style Options

\pagestyle{fancy}                       % Sets fancy header and footer
\fancyfoot{}                            % Delete current footer settings

%\renewcommand{\chaptermark}[1]{         % Lower Case Chapter marker style
%  \markboth{\chaptername\ \thechapter.\ #1}}{}} %

%\renewcommand{\sectionmark}[1]{         % Lower case Section marker style
%  \markright{\thesection.\ #1}}         %

\fancyhead[LE,RO]{\bfseries\thepage}    % Page number (boldface) in left on even
% pages and right on odd pages
\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\thechapter.\ #1}}{}}
\fancyhead[RE]{\bfseries\nouppercase{\leftmark}}      % Chapter in the right on even pages
\fancyhead[LO]{\bfseries\nouppercase{\rightmark}}     % Section in the left on odd pages

\let\headruleORIG\headrule
\renewcommand{\headrule}{\color{black} \headruleORIG}
\renewcommand{\headrulewidth}{1.0pt}
\usepackage{colortbl}
\arrayrulecolor{black}

\fancypagestyle{plain}{
  \fancyhead{}
  \fancyfoot{}
  \renewcommand{\headrulewidth}{0pt}
}

\usepackage{algorithm}
\usepackage[noend]{algorithmic}


%%% Clear Header %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Clear Header Style on the Last Empty Odd pages
\makeatletter

\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else%
  \hbox{}%
  \thispagestyle{empty}%              % Empty header styles
  \newpage%
  \if@twocolumn\hbox{}\newpage\fi\fi\fi}

\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Prints your review date and 'Draft Version' (From Josullvn, CS, CMU)
\newcommand{\reviewtimetoday}[2]{\special{!userdict begin
    /bop-hook{gsave 20 710 translate 45 rotate 0.8 setgray
      /Times-Roman findfont 12 scalefont setfont 0 0   moveto (#1) show
      0 -12 moveto (#2) show grestore}def end}}
% You can turn on or off this option.
%\reviewtimetoday{\today}{Draft Version}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{multirow}
\usepackage{slashbox}

\renewcommand{\epsilon}{\varepsilon}

% centered page environment

\newenvironment{vcentrepage}
{\newpage\vspace*{\fill}\thispagestyle{empty}\renewcommand{\headrulewidth}{0pt}}
{\vspace*{\fill}}


\renewcommand{\figurename}{Figure~}
%\usepackage[small,bf]{caption}

\addtokomafont{caption}{\small}
\setkomafont{captionlabel}{\small\bfseries}

\setcapindent{0em}
\usepackage{ifpdf}

\usepackage[b5paper,hyperindex=true,plainpages=false]{hyperref}


\renewcommand{\thefootnote}{\roman{footnote}}
\def\sectionautorefname{Section}
\def\subsectionautorefname{Section}
\def\subsubsectionautorefname{Section}
\usepackage{pdflscape}

\newenvironment{mysidewaystable}[1][htp]{\begin{sidewaystable}[#1]}{\end{sidewaystable}}

\renewcommand{\topfraction}{0.7}    % max fraction of floats at top
\renewcommand{\bottomfraction}{0.75}    % max fraction of floats at bottom
%   Parametres for TEXT pages (not float pages):
\setcounter{topnumber}{2}
\setcounter{bottomnumber}{1}
\setcounter{totalnumber}{3}     % 2 may work better
 \setcounter{dbltopnumber}{2}    % for 2-column pages
\renewcommand{\textfraction}{0.05}  % allow minimal text w. figs
%   Parametres for FLOAT pages (not text pages):
\renewcommand{\floatpagefraction}{0.6}  % require fuller float pages
% N.B.: floatpagefraction MUST be less than topfraction !!
\usepackage[title,toc]{appendix}


% % % % % % % % %indice di capitolo
\def\ptctitle{indice di capitolo}                     % scrive quello che c'è tra {} al posto di Indice o Contents nei minitoc
\def\mtctitle{indice di capitolo}
\def\stctitle{indice di capitolo}
\setlength{\mtcindent}{3pt}               % indentazione del titolo del minitoc
\renewcommand{\mtifont}{
\small\scshape\lsstyle}  

 \usepackage{tocbibind}
\usepackage{mathtools}

\definecolor{NatGreen}{RGB}{50,93,61}
\newcolumntype{x}[1]{%
>{\raggedleft\hspace{0pt}}m{#1}}%


\hyphenation{mo-le-cu-lar ful-le-ro-pyr-ro-li-di-ne ful-le-ro-pyr-ro-li-di-nes his-to-grams his-to-gram pla-te-aus}

\hypersetup
{pdftitle={Spectroscopic Tools for Quantitative Studies of DNA Structure and Dynamics.},
pdfauthor={Søren Preus},
pdfsubject={PhD thesis. ``Spectroscopic Tools for Quantitative Studies of DNA Structure and Dynamics.'' }, %subject of the document
%pdftoolbar=false, % toolbar hidden
pdfmenubar=true, %menubar shown
pdfhighlight=/O, %effect of clicking on a link
colorlinks=true, %couleurs sur les liens hypertextes
pdfpagemode=UseOutlines,%UseNone, %aucun mode de page
pdfpagelayout=TwoPageRight,%SinglePage, %ouverture en simple page
pdffitwindow=true, %pages ouvertes entierement dans toute la fenetre
linkcolor=black, %couleur des liens hypertextes internes
citecolor=black, %couleur des liens pour les citations
urlcolor=black, %couleur des liens pour les url
bookmarksopenlevel=2
}


\usepackage[style=numeric,backend=bibtex,refsegment=chapter]{biblatex}



\begin{document} 
\titleformat{name=\section,numberless}[hang]{\usekomafont{section}}{}{.0em}{}

\pagenumbering{roman}
\dominitoc

\mainmatter
\chapter{try try try try try try try try try try try try try try try try try try try try try try try try try try try try try try}
\textit{try try try}
\vfill %da lo spazio
\minitoc %crea il mini indice
\newpage
%----------------------------------------------------------------------------------------
\section{try try try try try try try try  try try try try try try try try try try try try try try try try try try try try try try}
try try try try try try try try try try try try try try try try try try try try try try try try try try try try try try

\end{document}

答案1

这里的问题是,您在 TikZ 中设置了部分标题\node,默认情况下这是一个不允许换行的框,它将变得与节点的内容一样宽。要解决此问题,请text width为设定一个node,这将导致节点文本在超出该宽度时中断。

您可能还想更改其中的anchornode或者如果它需要多行,您可能最终会将部分章节标题放在您绘制的线下方。

一个简单的例子:

在此处输入图片描述

\documentclass{scrartcl}

\usepackage{titlesec}
\usepackage{tikz}
\usetikzlibrary{calc,positioning}
\newcommand\boxedSectionB[3]{{%
     \begin{tikzpicture}[inner sep=#3,line width=1pt]
         \node[anchor=east,rectangle,draw,fill=black] at (0,0) (counter) {\color{white}\textbf{#2}};
         \draw (counter.south west) ++(.0pt,.5pt)-- ++($(\linewidth,0) - (2.5pt,0)$);
         \node [right=of counter.south east, % bottom right corner of box with section number
               anchor=south west,            % bottom left corner of section title box
               text width=.7\linewidth]      % Change the width to whatever you want
               {#1};
     \end{tikzpicture}
 }}
\newcommand\boxedsection[1]{\boxedSectionB{#1}{\thesection}{2mm}}
 \titleformat{\section}[hang]%
     {\usekomafont{section}}%
     {}%
     {.0em}%
     {\filright\boxedsection}%


\begin{document} 

\section{try try try try try try try try  try try try try try try try try try try try try try try try try try try try try try try}
try try try try try try try try try try try try try try try try try try try try try try try try try try try try try try

\end{document}

相关内容