如何激活连字功能?

如何激活连字功能?

无论我做什么,我的背面都不会为我的文档添加连字符。我已将其放入我的序言中:

\usepackage[british,UKenglish,USenglish,english,american]{babel}

可能出了什么问题?

前言:

\documentclass[english,a4paper,11pt,fleqn,oneside,opgenany,oldfontcommands]{memoir}     % Openright aabner kapitler paa hoejresider (openany = vilkaarlig/begge)



\usepackage[T1]{fontenc}
\makeatletter
\setlength{\@fptop}{0pt}
\makeatother
\usepackage{tabularx}


\usepackage[utf8]{inputenc}                 
\usepackage[T1]{fontenc}                    
\usepackage[english]{babel}             
\usepackage{ragged2e,anyfontsize}           
            
\usepackage{rotating}                   


\usepackage{nomencl}


\renewcommand\arraystretch{1.5}               
\usepackage{graphicx}                       
\usepackage{multirow}                   
\usepackage{colortbl}                       
\usepackage[dvipsnames]{xcolor}         
\usepackage{flafter}                        
\usepackage{float}                          
\begin{figure}[H]
\usepackage{placeins}
\let\newfloat\relax                                             
\usepackage{lscape}                 
\begin{sideways}...\end{sideways}
\usepackage{gensymb}


\usepackage{amsmath,amssymb,stmaryrd}       
\usepackage{mathtools}                      
\usepackage{textcomp}                       
\textperthousand)
\usepackage{siunitx}                        
\sisetup{output-decimal-marker = {,}}       
\usepackage[english]{varioref}              
\usepackage[super]{natbib}                  
\externaldocument{<NAVN>}




\usepackage{listings}                       
\begin{lstlisting}...\end{lstlisting}
\usepackage{lipsum}                         
\usepackage[shortlabels]{enumitem}          
\usepackage{pdfpages}                           
\pdfoptionpdfminorversion=6                 
\pretolerance=2500                          


\usepackage[footnote,draft,english,silent,nomargin]{fixme}      



\setlrmarginsandblock{2.5cm}{2.5cm}{*}  
\setlrmarginsandblock{Indbinding}{Kant}{Ratio}
\setulmarginsandblock{2.5cm}{2.5cm}{*}      
\setulmarginsandblock{Top}{Bund}{Ratio}
\checkandfixthelayout                   
\usepackage[footnote,draft,english,silent,nomargin]{fixme}
%   ¤¤ Afsnitsformatering ¤¤ %
\setlength{\parindent}{0mm}                 
\setlength{\parskip}{3mm}                   
\linespread{1,1}                            

% ¤¤ Litteraturlisten ¤¤ %
\bibpunct[,]{[}{]}{;}{a}{,}{,}              
\bibliographystyle{unsrt}               


% ¤¤ Dybde af overskrifter ¤¤ %
\setsecnumdepth{subsection}             
\settocdepth{subsection}                    

% ¤¤ Lister ¤¤ %
\setlist{
  topsep=0pt,                               
  itemsep=-1ex,                             
} 


\usepackage[colorlinks]{hyperref}           
\hypersetup{colorlinks = true,              
    linkcolor = black,
    citecolor = black,
    urlcolor = black
}


\usepackage[flushleft]{threeparttable}      
\captionnamefont{\small\bfseries\itshape}   
\captiontitlefont{\small}
\usepackage{hhline} %bruges til at lave dobbeltlinjer horisontalt i tabeller
\usepackage{booktabs}
\usepackage[labelfont={small,bf, it}]{caption}


\captiondelim{. }   
\hangcaption                             
\captionstyle{\centering}                   
%\captionwidth{\linewidth}                  
\setlength{\belowcaptionskip}{0pt}          
        

\definecolor{commentGreen}{RGB}{34,139,24}
\definecolor{stringPurple}{RGB}{208,76,239}

\lstset{language=Matlab,                    
    basicstyle=\ttfamily\scriptsize,        
    keywords={for,if,while,else,elseif,     
              end,break,return,case,
              switch,function},
    keywordstyle=\color{blue},              
    commentstyle=\color{commentGreen},      
    stringstyle=\color{stringPurple},       
    showstringspaces=false,                 
    numbers=left, numberstyle=\tiny,        
    extendedchars=true,                     
    columns=flexible,                       
    breaklines, breakatwhitespace=true,     
}


% ¤¤ Navngivning ¤¤ %
%\addto\captionsdanish{
    %\renewcommand\contentsname{Indholdsfortegnelse}            
    %\renewcommand\appendixname{Appendiks}                  
    %\renewcommand\appendixpagename{Appendiks}
    %\renewcommand\appendixtocname{Appendiks}
    %\renewcommand\cftchaptername{\chaptername~}                
    %\renewcommand\cftappendixname{\appendixname~}          
%}


\definecolor{numbercolor}{gray}{0.7}    
\newif\ifchapternonum

\makechapterstyle{jenor}{                   
  \renewcommand\beforechapskip{0pt}
  \renewcommand\printchaptername{}
  \renewcommand\printchapternum{}
  \renewcommand\printchapternonum{\chapternonumtrue}
  \renewcommand\chaptitlefont{\fontfamily{pbk}\fontseries{db}\fontshape{n}\fontsize{20}{30}\selectfont\raggedleft}
  \renewcommand\chapnumfont{\fontfamily{pbk}\fontseries{m}\fontshape{n}\fontsize{0.9in}{0in}\selectfont\color{numbercolor}}
  \renewcommand\printchaptertitle[1]{%
    \noindent
    \ifchapternonum
    \begin{tabularx}{\textwidth}{X}
    {\let\\\newline\chaptitlefont ##1\par} 
    \end{tabularx}
    \par\vskip-2.5mm\hrule
    \else
    \begin{tabularx}{\textwidth}{Xl}
    {\parbox[b]{\linewidth}{\chaptitlefont ##1}} & \raisebox{-15pt}{\chapnumfont \thechapter}
    \end{tabularx}
    \par\vskip2mm\hrule
    \fi
  }
}                                           

\chapterstyle{jenor}                    

\usepackage{lastpage}       
\usepackage{fancyhdr} 
\pagestyle{fancy}
\fancyhf{}
\rhead{Aalborg University}
\lhead{\leftmark}                               
\rfoot{Page \thepage\ of \pageref{LastPage}}    
\usepackage{lipsum}

\renewcommand{\footrulewidth}{1pt}            



\figur{Stoerrelse}{Fil}{Figurtekst}{Label}
\newcommand{\figur}[4]{
        \begin{figure}[H] \centering
            \includegraphics[width=#1\textwidth]{billeder/#2}
            \caption{#3}
            \label{#4}
        \end{figure} 
}


\newcommand{\dec}{^{\circ}}                                 % '\dec' returnerer et gradtegn (husk 
\newcommand{\decC}{^{\circ}\text{C}}                        % '\decC' returnerer et gradtegn + 'C' 
\newcommand{\m}{\cdot}                                      % '\m' returnerer et gangetegn



\hyphenation{In-te-res-se e-le-ment}


\usepackage{caption}
\usepackage{subcaption}

答案1

这是一个很好的例子,说明序言应该如何不是被写入。

它以难以分解的方式混合了包加载和设置;存在重复调用和可疑设置:例如,memoir有自己的设置页眉和页脚的方法,这fancyhdr不是完成这项工作的最佳选择。

你做得更糟

\usepackage[british,UKenglish,USenglish,english,american]{babel}

因为一份文件应该只使用一种英语方言。此外,british与 相同UKenglish,而USenglishenglish完全相同american

但这与缺少连字符无关:你会发现隐藏在令人困惑的序言中

\pretolerance=2500

这看起来像是一个无辜的声明,但实际上它告诉 TeX,荒谬糟糕的段落是好的,当整体不良程度为 2500 或更低时,不应尝试使用连字符。只有当不良程度超过 2500 时,才会尝试使用连字符。

事实上,当尝试排版一个段落时,TeX 会先进行第一遍排版,而不尝试使用连字符。如果 badness 不超过\pretolerance,则排版该段落。否则,将使用连字符执行第二遍,相关参数为。如果为正值,并且 badness 超过 ,\tolerance则可能会尝试第三遍。标准值为\emergencystretch\tolerance

\pretolerance=100
\tolerance=200

以下是一个例子:

\documentclass[twocolumn]{article}
\usepackage[textwidth=400pt]{geometry}
\usepackage{kantlipsum}

\begin{document}

\kant[2]

\newpage

\pretolerance=2500

\kant[2]

\end{document}

在此处输入图片描述

第二段的行数在任何阶段都不超过 2500,因此该段落可以不用连字符排版。但有一行的行数为 1231,即以“faculties”开头的一行。还有一行。

这是序言的修订版本;请看标有 的评论<---

\documentclass[
  english,
  a4paper,
  11pt,
  fleqn,
  oneside,
  openany, % <--- not opgenany
  %oldfontcommands, % <--- DON'T!!!
]{memoir}     % Openright aabner kapitler paa hoejresider (openany = vilkaarlig/begge)

\usepackage[T1]{fontenc}
%\usepackage[utf8]{inputenc} % <--- no longer necessary
\usepackage[english]{babel}             

\usepackage{tabularx}
\usepackage{graphicx}                       
\usepackage{rotating}                   
\usepackage{nomencl}
\usepackage{multirow}                   
%\usepackage{colortbl} % <--- pass table to xcolor
\usepackage[dvipsnames,table]{xcolor}
%\usepackage{flafter}
%\usepackage{float} % <--- DON'T use [H] under any circumstance
%\usepackage{placeins}
\usepackage{ragged2e}
\usepackage{lscape}
%\usepackage{gensymb} % <--- dubious usefulness
\usepackage{amsmath,amssymb,stmaryrd}       
\usepackage{mathtools}
%\usepackage{textcomp} % <--- no longer necessary
\usepackage{siunitx}                        
\usepackage[super]{natbib}                  
\usepackage{listings}                       
\usepackage[shortlabels]{enumitem}          
\usepackage{pdfpages}                           
\usepackage[footnote,draft,english,silent,nomargin]{fixme}      
%\usepackage{anyfontsize} % <--- obsolete
\usepackage[flushleft]{threeparttable}      
\usepackage{hhline} %bruges til at lave dobbeltlinjer horisontalt i tabeller
\usepackage{booktabs}
\usepackage[labelfont={small,bf, it}]{caption}
\usepackage{subcaption}
\usepackage{lastpage}       
\usepackage{fancyhdr} % <--- it would be better to use memoir features

\usepackage[english]{varioref}              
\usepackage[colorlinks]{hyperref}           

%% settings

\makeatletter
\setlength{\@fptop}{0pt}
\makeatother

\renewcommand\arraystretch{1.5} % <--- Really?

\sisetup{output-decimal-marker = {,}}       

\setlrmarginsandblock{2.5cm}{2.5cm}{*}  
\setlrmarginsandblock{Indbinding}{Kant}{Ratio}
\setulmarginsandblock{2.5cm}{2.5cm}{*}      
\setulmarginsandblock{Top}{Bund}{Ratio}
\checkandfixthelayout                   
%   ¤¤ Afsnitsformatering ¤¤ %

\setlength{\parindent}{0mm}                 
\setlength{\parskip}{3mm}                   
\linespread{1.1} % <--- NOT 1,1

% ¤¤ Litteraturlisten ¤¤ %
\bibpunct[,]{[}{]}{;}{a}{,}{,}              
\bibliographystyle{unsrtnat} % <--- unsrt is not compatible with natbib               


% ¤¤ Dybde af overskrifter ¤¤ %
\setsecnumdepth{subsection}             
\settocdepth{subsection}                    

% ¤¤ Lister ¤¤ %
\setlist{
  topsep=0pt,                               
  itemsep=-1ex,                             
} 


\hypersetup{
    colorlinks = true,
    linkcolor = black,
    citecolor = black,
    urlcolor = black
}

% <--- the following should be done with caption features
%\captionnamefont{\small\bfseries\itshape}
%\captiontitlefont{\small}
%\captiondelim{. }   
%\hangcaption                             
%\captionstyle{\centering}
%\captionwidth{\linewidth}
%\setlength{\belowcaptionskip}{0pt}

\definecolor{commentGreen}{RGB}{34,139,24}
\definecolor{stringPurple}{RGB}{208,76,239}
\definecolor{numbercolor}{gray}{0.7}

\lstset{language=Matlab,
    basicstyle=\ttfamily\scriptsize,
    keywords={for,if,while,else,elseif,
              end,break,return,case,
              switch,function},
    keywordstyle=\color{blue},
    commentstyle=\color{commentGreen},
    stringstyle=\color{stringPurple},
    showstringspaces=false,
    numbers=left,
    numberstyle=\tiny,
    extendedchars=true,
    columns=flexible,
    breaklines,
    breakatwhitespace=true,
}


\newif\ifchapternonum

\makechapterstyle{jenor}{                   
  \renewcommand\beforechapskip{0pt}
  \renewcommand\printchaptername{}
  \renewcommand\printchapternum{}
  \renewcommand\printchapternonum{\chapternonumtrue}
  \renewcommand\chaptitlefont{\fontfamily{pbk}\fontseries{db}\fontshape{n}\fontsize{20}{30}\selectfont\raggedleft}
  \renewcommand\chapnumfont{\fontfamily{pbk}\fontseries{m}\fontshape{n}\fontsize{0.9in}{0in}\selectfont\color{numbercolor}}
  \renewcommand\printchaptertitle[1]{%
    \noindent
    \ifchapternonum
    \begin{tabularx}{\textwidth}{X}
    {\let\\\newline\chaptitlefont ##1\par} 
    \end{tabularx}
    \par\vskip-2.5mm\hrule
    \else
    \begin{tabularx}{\textwidth}{Xl}
    {\parbox[b]{\linewidth}{\chaptitlefont ##1}} & \raisebox{-15pt}{\chapnumfont \thechapter}
    \end{tabularx}
    \par\vskip2mm\hrule
    \fi
  }
}                                           

\chapterstyle{jenor}                    

\pagestyle{fancy}
\fancyhf{}
\rhead{Aalborg University}
\lhead{\leftmark}                               
\rfoot{Page \thepage\ of \pageref{LastPage}}    
\usepackage{lipsum}

\renewcommand{\footrulewidth}{1pt}            

\newcommand{\dec}{^{\circ}}                                 % '\dec' returnerer et gradtegn (husk 
\newcommand{\decC}{^{\circ}\text{C}}                        % '\decC' returnerer et gradtegn + 'C' 
\newcommand{\m}{\cdot}                                      % '\m' returnerer et gangetegn



%\hyphenation{In-te-res-se e-le-ment} % <--- wrong hyphenations for English

答案2

我删掉了

\pretolerance=2500                      

现在它可以工作了。

相关内容