節前後有空格

節前後有空格

我在段落之間的文字[參見圖片]內有額外的空間。除此之外,[這個空間]的大小也不同。更重要的是,在部分之前和部分標題之後還有額外的空間。不同部分標題中的大小也不同。 在此輸入影像描述 在此輸入影像描述 在此輸入影像描述 如何修復它?

    \documentclass[openany]{book}
    \usepackage[utf8]{inputenc}
    \usepackage[MeX]{polski}
    \usepackage{xcolor}
    \usepackage{lipsum}
    \usepackage[explicit]{titlesec}
    \usepackage[dotinlabels]{titletoc}
    \usepackage{setspace}
    \onehalfspacing
    \usepackage[protrusion=true,expansion=true]{microtype}
    \usepackage{lettrine}
    \usepackage{titlesec}
    %\titleformat{\section}{\normalfont\bfseries}{\thesection}{1em}{}
    %\linespread{0.9}
    \newlength\BoxWd
    \setlength\BoxWd{0.75cm}
    \newlength\Aux
    \usepackage[left=4.65cm, right=4.65cm, top=4cm, bottom=4.25cm]{geometry}

    % chapter tiltes formatting
    \titleformat{\chapter}[display]
     {\normalfont\sffamily\huge}
     {\renewcommand{\thechapter}{\Roman{chapter}}%
      \settowidth\Aux{\textcolor{white}{\Huge\thechapter}}
      \ifnum\Aux>\BoxWd
        \setlength\BoxWd{\Aux}
      \else\fi
     \hspace*{0.3em}\colorbox{black}{%
     \parbox[c][1.2cm][c]{\BoxWd}{%
      \centering\textcolor{white}{\Huge\thechapter}}}}
      {-1ex}
      {\titlerule\vspace{.7ex}\filleft\MakeUppercase{#1}}
      [\vspace{.2ex}\titlerule]
     \titlespacing*{\chapter}{0pt}{50pt}{80pt}
     \titleformat{\section}
      {\scshape\normalsize\bfseries}{\MySecSquare\ \thesection.}{0.15em}{#1}
       \titlespacing*{\section}{0pt}{2.5pt}{1.5pt}

       \titleformat{\subsection}
       {\normalfont\scshape\normalsize\bfseries}{\MySecSquare\ \thesubsection.} {0.10em}{#1}
      \titlespacing*{\subsection}{0pt}{1.5pt}{0.5pt}

      % formatting for chapter entries in ToC  
      \titlecontents{chapter}
      [3em]{\vspace*{5.5pt}}
      {\small\bfseries{\hspace*{-2.63em}{\chaptername}\hspace*  {5pt}\contentslabel{0.25em}\hspace*{1.25em}}}
      {\hspace*{-3em}}
      {\titlerule*[1pc]{.}\small\sffamily\bfseries\contentspage}

      % formatting for section entries in ToC  
      \titlecontents{section}
      [4em]{\vspace*{-2pt}}
      {\small\contentslabel{2.5em}}
      {\hspace*{2.75em} }%\hspace*{-2.3em}
      {\titlerule*[1pc]{.}\small\sffamily\contentspage}

      \titlecontents{subsection}
      [7em]{\vspace*{-2pt}}
      {\small\contentslabel{2.85em}}
      {\hspace*{6em}}
      {\titlerule*[1pc]{.}\small\sffamily\contentspage}

      \newcommand\MySquare{%
      \leavevmode\hbox to 1.2ex{\hss\vrule height .9ex width .7ex depth -.2ex\hss}}

      \newcommand\MySecSquare{%
      \leavevmode\hbox to 1.2ex{\hss\vrule height 1.3ex width 1.1ex depth -.2ex\hss}}

      \renewcommand\labelitemi{\MySquare}

      \newenvironment{myquote}{\list{}{\leftmargin=15pt\rightmargin=0.0pt}\item[]}{\endlist}
      \newcommand\MyTitle{Some title}
      \usepackage{fancyhdr}
      \fancyhf{}
      \fancyhead[EL,OR]{\thepage}
      \fancyhead[OL]{\scriptsize\scshape{\leftmark}}
      \fancyhead[ER]{\footnotesize\scshape{\MyTitle}}
      \renewcommand\headrulewidth{0.2pt}


      \pagestyle{fancy}

      \newcommand{\initial}[1]{%
        \lettrine[lines=2,lhang=0.35,nindent=0em]{
                    \color{black}
                    {{#1}}}{}}
       \renewcommand\chaptermark[1]{\markboth{\thechapter.\ #1}{}} 
        \usepackage{hyperref}
       \hypersetup
        {   
        colorlinks,
        citecolor=black,
        filecolor=black,
        linkcolor=black,
        urlcolor=black,
        pdfauthor = {Pdfautor},
        pdftitle = {My title},
        pdftex
         }

         \begin{document}

        \frontmatter

        \tableofcontents
        \clearpage

        \newpage
        \thispagestyle{empty}



        \mainmatter
        \chapter*{Na wstępie}\label{chap:one}
        \addcontentsline{toc}{chapter}{\bfseries{Na wstępie}\vspace*{2em}}
        \setcounter{page}{9}

        \section{Section One}
        \lipsum[1-10]
        \section{Section two}
        \lipsum[1]
        \section{Section 3}
        \section{Section 4}
        \lipsum[1-10]
        \section{Section 5}
        \lipsum[1-2]
        \section{Section 6}
        \lipsum[1]
        \section{Section 7}
        \lipsum[1-20]
        \chapter{Second chapter}
        \section{someSection}
        \lipsum[1-20]
        \section{someSection2}
        \lipsum[1-20]
        \chapter{Last chapter}
        \end{document}

答案1

這個問題可能已經在問題中得到了回答確保頁面底部(和頂部)之間的文字對齊

嘗試新增選項paper=a4paper,twoside=true,textheight=45\baselineskip+\topskip

geometry文件中的 - 選項。您還必須使用該套件calc

\usepackage{calc}
\usepackage[paper=a4paper,
            twoside=true,
            bindingoffset=0cm,
            textheight=45\baselineskip+\topskip,
            left=4.65cm, right=4.65cm, top=4cm, bottom=4.25cm
            ]{geometry}

在您的 MWE 中(但也許在真實文檔中),這並不能解決間距問題,因為您必須在 之後添加少量文本section 0.2,然後是兩個小節,中間沒有任何文本。LaTeX沒有找到好的地方分頁。如果您使用真實文本,或使用\lipsum[2-3]after section 0.2,空格也會消失。您也可以使用命令

\enlargethispage{2\baselineskip}

或者

\enlargethispage{-\baselineskip}

在有問題的頁面上新增或刪除一些行。

問題來自於以下事實:book-class 使用flushbottom預設值,因此會在頂部和底部邊距之間拉伸文字。如果將該選項新增raggedbottom至類別選項中,問題就會永久消失。

道德是:如果您希望文字在頂部和底部邊距之間刷新,則必須在完成所有編輯後仔細瀏覽文件。在最後的修改中,您可以進行細微的更改來修正此類排版錯誤。但您將無法自動處理所有此類問題。

相關內容