我将“报告”文档类用于用瑞典语编写的文档(其中有 åäöÅÄÖ)。我还使用 babel 包来处理瑞典语。它按预期工作,但现在 LaTeX 无法用连字符连接我的一些特殊单词,因此我不得不添加以下内容:
\hyphenation{
nät-spänn-ing
nät-spänn-ing-ar
lik-spänn-ing
spänn-ing
spänn-ing-en
belys-nings-lamp-orna
}
但是,为了将瑞典语单词连字符化,我还需要添加:
\usepackage[T1]{fontenc}
否则我会得到一些致命的错误,而谷歌告诉我使用上面的行。
但是,使用 T1 时,整个文档中每个章节名称的所有 åäöÅÄÖ 都会被删除。文档本身仍然有 åäöÅÄÖ,但章节名称消失了。
问题:如何为瑞典语单词添加特殊连字符规则而不破坏包含瑞典语字符的部分名称?
(请参阅底部的更新问题)
编辑
我的问题不完整,因为缺乏适当的示例。以下是错误截图:
这是来源:
% -*- latex -*-
\documentclass[12pt,a4paper,twoside]{report}
\newif\iflargephoto
\largephototrue
\usepackage{xjobb}
\usepackage[T1]{fontenc}
\hyphenation{
nät-spänn-ing
nät-spänn-ing-ar
lik-spänn-ing
spänn-ing
spänn-ing-en
belys-nings-lamp-orna
}
\usepackage[swedish]{babel} % date format and hyphenation rules(?)
\selectlanguage{swedish}
\usepackage[utf8]{inputenc}
\begin{document}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pagenumbering{arabic}
\chapter{Swedish chars: å and ä and ö}
Swedish chars: å and ä and ö
\end{document}
如果我删除该行\usepackage[T1]{fontenc}
,则可以在章节标题中看到瑞典字符,但随后会\hyphenation{}
完全中断:
! Improper \hyphenation will be flushed.
\leavevmode ->\unhbox
\voidb@x
l.12 nä
t-spänn-ing
! Not a letter.
\leavevmode ->\unhbox \voidb@x
l.12 nä
t-spänn-ing
! Improper \hyphenation will be flushed.
[...lots of repeated errors cut away...]
漂亮的章节名称显然是由包生成的xjobb
(瑞典俚语“ex-jobb”,即“论文”)。删除这个和åäöÅÄÖ可以在章节名称中看到,但看起来太无聊了,所以我真的不想删除它。
我没有写过,也没有碰过 -package xjobb
。我大学里的很多人在论文中用过它,但不同之处在于他们用英语写过,从来没有遇到过我的问题,这可能就是为什么没有人注意到这些错误的原因。
-packagexjobb
相当小所以我将它添加到这里:
% START xjobb-package
%
% Package file with options making me feel better...
% (Author: Stefan Langemark)
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{xjobb}[1999/04/16 Class setup for xjobb]
\RequirePackage{parskip}
\RequirePackage{geometry}
\RequirePackage[utf8]{inputenc}
\RequirePackage{fancyhdr}
%
%--------------------------------
% Paper layout
% (no room for margin notes)
%--------------------------------
%
% paper=b5paper,
\geometry{
paperwidth = 165mm, paperheight = 240mm,
% paper = a4paper,
total = {130mm,220mm},
% marginparsep = 2mm,
% marginparwidth = 15mm,
includemp = false,
%twosideshift = 10pt
}
\addtolength{\headheight}{3pt}
%-------------------------------
% Header/Footer
%-------------------------------
\renewcommand{\headrulewidth}{0.4pt}
\fancyhf{}
\fancyhead[LO]{\bfseries\rightmark}
\fancyhead[RE]{\bfseries\leftmark}
\fancyhead[RO,LE]{\bfseries\thepage}
\pagestyle{fancy}
%\pagestyle{plain}
\fancypagestyle{plain}{%
\fancyhf{}%
\renewcommand{\headrulewidth}{0pt}
}
%
%-------------------------------
% Redefining section styles
% to suit parskip > 0
%-------------------------------
%
%\addtocounter{secnumdepth}{1}% Number subsubsections too
%\addtocounter{tocdepth}{1}% Include subsections in table of contents.
\renewcommand\section{\@startsection%
{section}%
{1}%
{\z@}%
{-2.5ex \@plus -1ex \@minus -.2ex}%
{1.3ex \@plus.2ex}%
{\normalfont\Large\bfseries}%
}
\renewcommand\subsection{\@startsection%
{subsection}%
{2}%
{\z@}%
{-2.25ex\@plus -1ex \@minus -.2ex}%
{0.5ex \@plus .2ex}%
{\normalfont\large\bfseries}%
}
\renewcommand\subsubsection{\@startsection%
{subsubsection}%
{3}%
{\z@}%
{-2.25ex\@plus -1ex \@minus -.2ex}%
{0.1pt \@plus .2ex}%
{\normalfont\mdseries\large\itshape}%
}
%
%-------------------------------------
% Redefine {chapter,section}mark to
% remove ugly all-uppercase
%-------------------------------------
%
\renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter.\enspace #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\enspace #1}}
%
%
\renewcommand\tableofcontents{%
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\chapter*{\contentsname}%
\markboth{\contentsname}{\contentsname}%
\@starttoc{toc}%
\if@restonecol\twocolumn\fi
}
\renewcommand\listoffigures{%
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\chapter*{\listfigurename}%
\markboth{\listfigurename}{\listfigurename}%
\@starttoc{lof}%
\if@restonecol\twocolumn\fi
}
\renewcommand\listoftables{%
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\chapter*{\listtablename}%
\markboth{\listtablename}{\listtablename}%
\@starttoc{lot}%
\if@restonecol\twocolumn\fi
}
%
%-------------------------------------------
% Chapter (stolen from Kluwer book style)
%-------------------------------------------
%
\font\chapnumber=cmbx10 at 50pt %% chapter number
%\font\chaptitle=cmbx10 scaled\magstep3 %% chapter title
\font\chaptitle=cmbx10 at 20pt %% chapter title
\def\bigraggedleft{\leftskip0pt plus1fil\relax}
\def\@makechapterhead#1{%\null\vskip-5pc
\vbox to 14pc{\hbox to\textwidth{\hfill\chapnumber\thechapter}
\hyphenpenalty=10000 % No hyphenation in chapter heads
\vskip8pt
\hrule height 1.5pt
\vskip12pt\vskip-\parskip
\def\\ {\vskip-\parskip}\parfillskip=0pt
\bigraggedleft
\LARGE\chaptitle{\def\\ {\vskip-\parskip}#1}\vskip1sp
\vfill}}
\def\@makeschapterhead#1{\vbox to 7.5pc{
\hrule height 1.5pt
\hyphenpenalty=10000 % No hyphenation in chapter heads
\vskip12pt\vskip-\parskip
\def\\ {\vskip-\parskip}\parfillskip=0pt
\LARGE\bigraggedleft
\chaptitle{#1}\vskip1sp\vfill}}
% END xjobb-package
希望我现在已经收集了这个问题所需的所有信息,我真的希望我仍然可以使用-package,xjobb
因为我真的很喜欢它的外观。
所以,问题:是xjobb
-package 破坏了章节名称中的 åäöÅÄÖ 吗?如果是,我该如何重写它才能使其正常工作?
答案1
听着,我只是试图修复你的问题,但恐怕这个包需要经过广泛的审查。尝试将以下代码保存在与要编译的(主)文件相同的目录中,名称为newxbjobb.sty
:
% Package file with options making me feel better...
% (Author: Stefan Langemark)
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{newxjobb}[2018/11/16 *** To be reviewed! ***]
\RequirePackage{parskip}
\RequirePackage{geometry}
\RequirePackage[T1]{fontenc} % ... the following line doesn't make much sense
% without this one
\RequirePackage[utf8]{inputenc}
\RequirePackage{fancyhdr}
%
%--------------------------------
% Paper layout
% (no room for margin notes)
%--------------------------------
%
% paper=b5paper,
\geometry{
paperwidth = 165mm, paperheight = 240mm,
% paper = a4paper,
total = {130mm,220mm},
% marginparsep = 2mm,
% marginparwidth = 15mm,
includemp = false,
%twosideshift = 10pt
}
\addtolength{\headheight}{3pt} % ??? (use "\geometry{...}" instead!)
%-------------------------------
% Header/Footer
%-------------------------------
\renewcommand{\headrulewidth}{0.4pt}
\fancyhf{}
\fancyhead[LO]{\bfseries\rightmark}
\fancyhead[RE]{\bfseries\leftmark}
\fancyhead[RO,LE]{\bfseries\thepage}
\pagestyle{fancy}
%\pagestyle{plain}
\fancypagestyle{plain}{%
\fancyhf{}%
\renewcommand{\headrulewidth}{0pt}
}
%
%-------------------------------
% Redefining section styles
% to suit parskip > 0
%-------------------------------
%
%\addtocounter{secnumdepth}{1}% Number subsubsections too
%\addtocounter{tocdepth}{1}% Include subsections in table of contents.
\renewcommand\section{\@startsection%
{section}%
{1}%
{\z@}%
{-2.5ex \@plus -1ex \@minus -.2ex}%
{1.3ex \@plus.2ex}%
{\normalfont\Large\bfseries}%
}
\renewcommand\subsection{\@startsection%
{subsection}%
{2}%
{\z@}%
{-2.25ex\@plus -1ex \@minus -.2ex}%
{0.5ex \@plus .2ex}%
{\normalfont\large\bfseries}%
}
\renewcommand\subsubsection{\@startsection%
{subsubsection}%
{3}%
{\z@}%
{-2.25ex\@plus -1ex \@minus -.2ex}%
{0.1pt \@plus .2ex}%
{\normalfont\mdseries\large\itshape}%
}
%
%-------------------------------------
% Redefine {chapter,section}mark to
% remove ugly all-uppercase
%-------------------------------------
%
\renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter.\enspace #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\enspace #1}}
%
%
\renewcommand\tableofcontents{%
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\chapter*{\contentsname}%
\markboth{\contentsname}{\contentsname}%
\@starttoc{toc}%
\if@restonecol\twocolumn\fi
}
\renewcommand\listoffigures{%
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\chapter*{\listfigurename}%
\markboth{\listfigurename}{\listfigurename}%
\@starttoc{lof}%
\if@restonecol\twocolumn\fi
}
\renewcommand\listoftables{%
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\chapter*{\listtablename}%
\markboth{\listtablename}{\listtablename}%
\@starttoc{lot}%
\if@restonecol\twocolumn\fi
}
%
%-------------------------------------------
% Chapter (stolen from Kluwer book style)
%-------------------------------------------
%
\newcommand*\chapnumber{% chapter number
\fontsize{50}{60}%
\usefont{T1}{lmr}{bx}{n}%
}
\newcommand*\chaptitle{% chapter title
\fontsize{20}{24}%
\usefont{T1}{lmr}{bx}{n}%
}
\def\bigraggedleft{\leftskip0pt plus1fil\relax}
\def\@makechapterhead#1{%\null\vskip-5pc
\vbox to 14pc{\hbox to\textwidth{\hfill\chapnumber\thechapter}
\hyphenpenalty=10000 % No hyphenation in chapter heads
\vskip8pt
\hrule height 1.5pt
\vskip12pt\vskip-\parskip
\def\\ {\vskip-\parskip}\parfillskip=0pt
\bigraggedleft
\chaptitle{\def\\ {\vskip-\parskip}#1}\vskip1sp
\vfill}}
\def\@makeschapterhead#1{\vbox to 7.5pc{
\hrule height 1.5pt
\hyphenpenalty=10000 % No hyphenation in chapter heads
\vskip12pt\vskip-\parskip
\def\\ {\vskip-\parskip}\parfillskip=0pt
\bigraggedleft
\chaptitle{#1}\vskip1sp\vfill}}
% END xjobb-package
然后,在主文件中,替换
\usepackage{xjobb}
和
\usepackage{newxjobb}
另外,删除两行
\usepackage[T1]{fontenc}
和
\usepackage[utf8]{inputenc}
来自您的主文件:它们不是/不再需要。