使用 XeLaTeX 消除书中不均匀的间距

使用 XeLaTeX 消除书中不均匀的间距

我不知道如何修复不需要的空格。这只出现在文本的某些位置。我的序言

    \documentclass[9.526pt]{book}
    \usepackage{amsmath,amsfonts,amsthm,amssymb,mathtools}
    \usepackage[varbb]{newpxmath}
    \usepackage{xfrac}
    \usepackage{float}
    \usepackage[makeroom]{cancel}
    \usepackage{mathtools}
    \usepackage{bookmark}
    \usepackage{mdframed}
    \usepackage{enumitem}
    \usepackage{hyperref,theoremref}
    \hypersetup{
        pdftitle={Assignment},
        colorlinks=true, linkcolor=myBlue,
        bookmarksnumbered=true,
        bookmarksopen=true
    }
    \usepackage[most,many,breakable]{tcolorbox}
    \usepackage{xcolor}
    \usepackage{varwidth}
    \usepackage{varwidth}
    \usepackage{etoolbox}
    %\usepackage{authblk}
    \usepackage{nameref}
    \usepackage{multicol,array}
    \usepackage{tikz-cd}
    \usepackage[ruled,vlined,linesnumbered]{algorithm2e}
    \usepackage{comment} % enables the use of multi-line comments (\ifx \fi) 
    \usepackage{import}
    \usepackage{xifthen}
    \usepackage{pdfpages}
    \usepackage{transparent}
    \usepackage{longtable}
    \usepackage{amssymb}
    \usepackage[showboxes,absolute]{textpos}
    \usepackage{ragged2e}
    \usepackage{fontspec}
    \usepackage{lipsum}
    \usepackage{titlesec}
    \usepackage{titleps}
    \usepackage{tikz}
    %\usepackage{parskip} %% <-- added
    
    \setlength{\abovedisplayskip}{0pt}
    \setlength{\belowdisplayskip}{0pt}
    \setlength{\abovedisplayshortskip}{0pt} 
    \setlength{\belowdisplayshortskip}{0pt}
    
    
    % The emptypage package prevents page numbers and
    % headings from appearing on empty pages.
    \usepackage{emptypage}
   \usepackage[paperwidth=20.5cm,paperheight=20.5cm, left=5.0cm, right=2.0cm, bottom=2.0cm, top=2.0cm, asymmetric]{geometry}
%asymmetric% <- added to have same margins for even and odd pages
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%% MY FONTS %%%%%%%%%%%%%%%%%%%%%%%%%

\setmainfont[
 BoldFont={TimesTenLTStd-Bold.otf}, 
 ItalicFont={TimesTenLTStd-Italic.otf},
 BoldItalicFont={TimesTenLTStd-BoldItalic.otf}
 ]{TimesTenLTStd-Roman.otf}

 
%sfsfamily font
  %\setsansfont{Libertinus Sans}

%\setsansfont[
 %BoldFont={Brandon_bld.otf}, 
 %ItalicFont={Brandon_reg_it.otf},
 %BoldItalicFont={Brandon_bld_it.otf}
 %]{Brandon_reg.otf}








% Allow per-chapter appendices
\usepackage[title,titletoc]{appendix}
\setcounter{tocdepth}{1}% -- part,chapters,sections
%%%%MY COLORS%%%%%%%%%%%%%%%%%%%%%%%
\definecolor{SteelBlue}{RGB}{70, 130, 180}
\definecolor{DodgerBlue}{RGB}{30, 144, 255}
\definecolor{CornflowerBlue}{RGB}{100, 149, 237}
\definecolor{IndianRed}{RGB}{205, 92, 92}
\definecolor{abetsaffron}{RGB}{255, 108, 44}
\definecolor{myBlue}{RGB}{8, 24, 168}
\definecolor{LightBlue}{rgb}{.8,.9,1}
%%%%%%%%%%%%%%%%%%%%%%
%MY CHAPTER
%%%%%%%%%%%%%%%%%%%%%%%
\newcounter{listingCtr}[chapter]
\renewcommand{\thelistingCtr}{\arabic{chapter}.\arabic{listingCtr}}
\usepackage{ifpdf}
\ifpdf
    %This is needed to keep unique links for hyperref
    \renewcommand{\theHlistingCtr}{\arabic{chapter}.\arabic{listingCtr}}
\fi
\newenvironment{codeexample}[1][]
{
    \par
    \refstepcounter{listingCtr}
    \ifthenelse{\equal{#1}{}}
    {
        \renewcommand{\listingFile}{ch\thechapter ex\arabic{listingCtr}.m}
    }
    {
        \renewcommand{\listingFile}{#1}
    }
}
{
    \lstinputlisting[caption=(\listingFile),frame=TB]{\listingFile}
}


% Page headers
   % \usepackage{calc}
    %\usepackage{fancyhdr}
    %  \fancyhf{}
      %\pagestyle{fancy}
       %\usepackage{titleps}
      \newpagestyle{main}{
   \sethead[\color{myBlue}\bfseries\thepage][\sffamily\chaptertitle][\sffamily Chap. \thechapter]  % even
           {\sffamily Sec. \thesection}{\sffamily\sectiontitle}{{\color{myBlue}\bfseries\thepage}}  \setheadrule{0.01cm}%
\widenhead[3.0cm][0.0cm]{3.0cm}{0.0cm}
} % odd
\pagestyle{main}
%\widenhead[even-left][even-right]{odd-left}{odd-right}
  
    



%--------this is to get chapter name as small caps and sansserif







%---toc chapter name sanserif
%\begin{comment}
    
\begin{comment}
   \makeatletter % default is "\newcommand\@chapapp{\chaptername}"
\renewcommand\@chapapp{{\Huge\scshape\sffamily{\chaptername}}}
\makeatletter 

%---------------------NEW SETUP---------------------


\newcommand{\chapnumfont}{%
  \fontsize{100}{100}\usefont{T1}{ptm}{b}{n}%
}

\colorlet{chapbgcolor}{gray!75}
\colorlet{chapnumcolor}{black!60}

\newcommand{\chaptitlenumbered}[1]{%
  \begin{tikzpicture}
  \fill[chapbgcolor!70,rounded corners=0pt] (0,2.3) rectangle (\linewidth,0);
  \node[
    align=right,
    anchor=south east,
    inner sep=8pt,
    font=\huge\normalfont\bfseries
  ] at (0.987\linewidth,0) {\strut#1};
  \node[
    align=right,
    font=\fontsize{60}{62}\usefont{OT1}{ptm}{b}{it},
    text=chapnumcolor
  ] at (0.975\linewidth,2.1) {\thechapter};
  \end{tikzpicture}%
}

\newcommand{\chaptitleunnumbered}[1]{%
  \begin{tikzpicture}
  \fill[chapbgcolor!70,rounded corners=0pt] (0,2.3) rectangle (\linewidth,0);
  \node[
    align=right,
    anchor=south east,
    inner sep=8pt,
    font=\huge\normalfont\bfseries
  ] at (0.987\linewidth,0) {\strut#1};
  \end{tikzpicture}%
}
\end{comment}

\titleformat{name=\chapter}[display]
  {\color{myBlue}\fontsize{25pt}{25pt}\normalfont\bfseries}
  {}
  {0pt}
  {\begin{tikzpicture}[remember picture, overlay]%
         % \pgftext[right,x=15cm,y=0.2cm]{\color{black}\Huge\sc\bfseries\contentsname};%
          \draw[draw=none,left color=myBlue, middle color = myBlue!70,right color=white] (-3,-0.70) rectangle (15,1);%
        %  \clip (10,-.75) rectangle (20,1);
          \pgftext[right,x=4.45cm,y=0.2cm]{\color{white}\Huge\scshape\sffamily\bfseries\chaptername \hspace{0.5cm}\thechapter};%
      \end{tikzpicture}%
   \newline
   \newline
   \newline\vspace*{.5\baselineskip}
    }
\titleformat{name=\chapter,numberless}[display]
  {\color{white}\Huge\scshape\sffamily\bfseries}
  {}
  {0pt}
 {\begin{tikzpicture}[remember picture, overlay]%
         % \pgftext[right,x=15cm,y=0.2cm]{\color{black}\Huge\sc\bfseries\contentsname};%
          \draw[draw=none,left color=myBlue, middle color = myBlue!70,right color=white] (-3,-0.70) rectangle (15,1);%
        %  \clip (10,-.75) rectangle (20,1);
          %\pgftext[right,x=3cm,y=0.2cm]{\color{white}\Huge\scshape\sffamily\bfseries\chaptername \hspace{0.5cm}\thechapter};%
      \end{tikzpicture}%
   }
\titlespacing*{\chapter}
  {0pt}
  {-4pt}
  {60pt}
\setlength\headheight{15pt}
%\setlength{\titlewidth}{0.5\textwidth}


% --- Plan A ---
\titleformat{\section}[block]
    {\hspace{-3em}\addvspace{0.8ex}%
    \sffamily\bfseries\huge} % format for the whole line
    {\color{myBlue}\thesection}% how to show number
    {0.5em} % space between number and text
    {}[{\color{myBlue}\addvspace{0.4ex}\titlerule[2.5pt]}]% formatting for after the text
\titlespacing*{\section}{-3em}{*2}{*2}
%\titlespacing{\section}{-3em}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
%55555555555555555555555555555555555555555555555555555555555

\titleformat{\subsection}% which section command to format
  {\color{myBlue}\addvspace{0.8ex}%
  \bfseries\Large\sffamily} % format for the whole line
  {} % how to show number
  {0pt} % space between number and text
  {\color{myBlue}} % formatting for just the text
  [] % formatting for after the text
%\titlespacing*{\subsection}{-3em}{*2}{*2}



%--------------------------------------------------------------------------------------------
\begin{comment}
    
\newcounter{example}[chapter]
\renewcommand{\theexample}{\arabic{example}}
\usepackage{ifpdf}
\ifpdf
    \renewcommand{\theHexample}{\arabic{example}} %This is needed to keep unique links for hyperref
\fi


\newenvironment{example}
    {\par\small \vspace{0pt}%
    \begin{enumerate}\item[]
     \refstepcounter{example}\hspace*{-3cm}\noindent\textbf{\small\color{myBlue}\sffamily EXAMPLE
     \theexample} \hspace*{0.185cm}} {\end{enumerate}  \vspace{0pt}}


\newenvironment{solution}
    {\par\small \vspace{0pt}%
     \refstepcounter{example}\hspace*{-0.50cm}\noindent{\small\normalfont\textit{\textbf{Solution:}}}} { \vspace{0pt}}
\end{comment}

\usepackage{mhchem}
\usepackage{chngcntr}
\counterwithout{equation}{chapter}
%\newcounter{problem}[chapter]
%\addtocounter{problem}{+1} % decreases some-counter by 1
%\renewcommand{\theproblem}{\arabic{problem}}
%\usepackage{ifpdf}
%\ifpdf
   % \renewcommand{\theHexample}{\arabic{problem}} %This is needed to keep unique links for hyperref
%\fi

%\newenvironment{example}[1][]{\refstepcounter{example}\par\medskip
 %  \noindent\textbf{Example~\theexample. #1} \rmfamily}{\medskip}

%\newcounter{problem}
%\newenvironment{problem}[1][chapter]
%  {\refstepcounter{problem}\vspace{1em plus 1em}
  % \begin{mdframed}[backgroundcolor=white]\textbf{#1 #2}}
 % {\end{mdframed}\vspace{-1em plus 1em}} 

\newcommand*\ssec[1]{\par%
   \vspace{1em}\textcolor{myBlue}{\hspace*{-0.50cm}\textbf{\Large\sffamily\noindent{#1}}}}
 
\newcounter{myvar}
%\addtocounter{myvar}{0}

  
\newcommand*\exm{\par%
    \refstepcounter{myvar}\vspace{1em}\textcolor{myBlue}{\hspace*{-3cm}\textbf{\sffamily EXAMPLE \themyvar\hspace*{0.50cm}\noindent}}}

\newcommand*\sol{\par%
    \vspace{1em}%
    \textcolor{black}{\hspace*{-0.50cm}{\it \textbf{Solution:} }}}


%\newcommand{\exProblem}{\hspace*{-3cm}\par\vspace{-10pt}\small\noindent}
%\newcommand{\exSolution}{\par\vspace{5pt}\noindent\textbf{\textit{Solution:}} }

%-----------------------------------------------------------------------------------------------
\usepackage{caption}
\captionsetup[figure]{labelfont={color=myBlue, bf}, name={Fig.},labelsep=period}

\renewcommand{\thefigure}{\arabic{figure}}
\usepackage{ifpdf}
\ifpdf
    \renewcommand{\theHfigure}{\arabic{figure}} %This is needed to keep unique links for hyperref
\fi`

 



    
   % **main file**
   % \input{preamble}
    \usepackage{graphicx} % Required for inserting images
    
    
    
    
    
    %\input{macros}
    \title{sandbox}
    \author{latex noob}
    \date{\today}
    
    \begin{document}
    \frenchspacing
    
    \maketitle
    
    \frontmatter %Use lowercase Roman numerals for page numbers
    
    \tableofcontents
    \clearpage
    
    \mainmatter
    \chapter{The Derivative}
    
    \section{Introduction}
    Consider a quantity \(y=f(x)\) whose value changes with \(x\). Let \(y_0=f(x_0)\) be the value of \(f(x)\) at \(x=x_0\) and \(y_{x_0+\Delta x}=f(x_0+\Delta x)\) at \(x_0+\Delta x\). The difference \(y_{x_0+\Delta x}-y_0=f(x_0+\Delta x)-f(x_0)\) indicates how \(f(x)\) has changed (increment or decrement) in the interval \((x_0,\;x_0+\Delta x)\) and the ratio
    \begin{align}\label{eq:1}
        \dfrac{f(x_0+\Delta x)-f(x_0)}{x_0+\Delta x-x_0}=\dfrac{\Delta f}{\Delta x},
    \end{align}
    shows how much \(f(x)\) has changed (increased or decreased) on  average per unit change in \(x\) in the interval \((x_0,\;x_0+\Delta x)\). That is, the ratio represents the {\it average rate of change of \(f(x)\)}. Now, The most interesting question we can ask ourselves is   how much did \(f(x)\) actually change at the point \(x_0\) alone?
    
    The answer to the above question can be obtained by making \(\Delta x\)  progressively smaller, that is, in the limit \(\Delta x\to 0\), then (\ref{eq:1}) yields the {\it (instantaneous) rate of change of \(f(x)\)} at \(x_0\). Mathematically,
    \begin{align}\label{eq:2}
        \lim\limits_{\Delta x\to 0}\;\dfrac{f\left(x_0+\Delta x\right)-f(x_0)}{\left(x_0+\Delta x\right)-x_0}.
    \end{align}
    
    Equation (\ref{eq:2}) is known as the {\it derivative} of \(f(x)\) with respect to \(x\) and is denoted by \(\dfrac{df\left(x\right)}{dx}\) or \(\dfrac{df}{dx}\) or \(f^{\prime}\).\footnote{As \(y=f(x)\),  \(\dfrac{dy}{dx}\)  or  \(y^{\prime}\) are often in literature to represent the derivative of \(y\) with respect to \(x\).}Therefore, 
    \begin{align}\label{eq:3}
      \dfrac{df}{dx}=  \lim\limits_{\Delta x\to 0}\;\dfrac{f\left(x_0+\Delta x\right)-f(x_0)}{\left(x_0+\Delta x\right)-x_0}.
    \end{align}
    \end{document}

1

相关内容