斜体在给定模板中不起作用

斜体在给定模板中不起作用

我使用以下模板: https://github.com/RUB-NDS/exposee_layout

我在“相关工作”章节末尾添加了以下代码:

\textit{TESTTESTTESTTESTTEST}
{\itshape abcdefgh}
non-italic \emph{should be italic} itshape: {\itshape should be italic} 
textit: \textit{should be italic}

这些都没有导致斜体我的文本样式。我还研究了我收到的警告:

在此处输入图片描述

但真的找不到任何解决方案。也许这里有人可以帮忙。我使用 pdflatex 进行编译。

谢谢大家。

问候

- - - - - - - - - - 更新 - - - - - - - - - -

你好,

首先感谢您的回复。

以下代码是我的mwe:

\documentclass[
fontsize=11pt,
paper=a4,
abstract=true,
numbers=noenddot,
listof=totoc,
bibliography=totoc,
open=right,
cleardoublepage=plain,
parskip=half+, % comment this out if you do not want an empty half line between paragraphs, but please read the KomaScript Guide and search for parskip (around page 82): ftp://ftp.dante.de/pub/tex/macros/latex/contrib/koma-script/scrguide.pdf
BCOR=1cm, % Bindekorrektur: Change this accordingly, also read the KomaScript Guide! Make sure you read the guide.
]{scrreprt}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\input{misc/preamble}
\setcounter{tocdepth}{3}  % Inhaltsverzeichnis bis Subsubsection
\setcounter{secnumdepth}{3} % Nummerierung bis Subsubsection

% General stuff
\usepackage{fixltx2e}
\usepackage[utf8]{inputenc} % CHANGE HERE IF NECESSARY
\usepackage[T1]{fontenc}
\usepackage[ngerman, english]{babel} % last language given is used (here: english)
\usepackage{lmodern}
%\usepackage{microtype}
\usepackage{ifpdf}
\usepackage{ifthen}

%%%%%% MACROS %%%%%%
\usepackage{xspace} % Nur dann ein Leerzeichen, wenn das nächste Zeichen kein Satzzeichen ist.
\newcommand{\SecII}{Sec\textsuperscript{2}\xspace}
\newcommand{\SAML}{\acr{SAML}\xspace}
\newcommand{\XML}{\acr{XML}\xspace}

% Set date here 
%\day=6 \month=6 \year=2012

% Set name and title
\author{Insert your name here}
\title{Insert title here}
\date{\today}

%%%%%% %%%%%%

% Load packages ...

% Corporate Design
\usepackage{eso-pic}
\usepackage{color}
% Comment out if the RUB fonts are installed
% Link: https://noc.rub.de/~jobsanzl/latex/rubtexfonts-0.4.tar.gz
%\usepackage{rubfonts2009} 
\newcommand{\setrubfontnormal}[1]{\fontfamily{rubscala}\fontsize{#1}{1}\selectfont}
\newcommand{\setrubfontextra}[1]{\fontfamily{rubflama}\fontsize{#1}{1}\selectfont}
\definecolor{rubgreen}{cmyk}{0.5,0,1,0}
\definecolor{rubblue}{cmyk}{1,0.5,0,0.6}

%Ganttchart
\usepackage{pgfgantt}

% Figures
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{placeins}

% Tables
\usepackage{booktabs}
\usepackage{marvosym}
\usepackage{multirow}

% Math stuff and units
\usepackage{latexsym,amsmath, amssymb, amsfonts, upgreek}
\usepackage{siunitx}
\newcommand{\mathup}{\mathrm}

% Glossary
\usepackage[nonumberlist, acronym, toc]{glossaries}
\makeglossaries

% Enable quotes by \enquote{}
\usepackage[babel,english=american, german=quotes]{csquotes}

% Necessary for frontpage, allows to create automata and fancy graphics
\usepackage{tikz}

% Protocols and bytefields
\usepackage{protocol}
\usepackage{bytefield}

% Source code listings
\newcommand{\code}[1]{\texttt{#1}}
\definecolor{colIdentifier}{rgb}{0,0,0}
\definecolor{colComments}{rgb}{0.5,0.5,0.5}
\definecolor{colKeys}{rgb}{0,0,1}
\definecolor{colString}{rgb}{0,0.6,0}

\usepackage{caption}
\usepackage{listings}
\lstset{%
    float=hbp,%
    basicstyle=\ttfamily\scriptsize, %
    identifierstyle=\color{colIdentifier}, %
    keywordstyle=\color{colKeys}, %
    stringstyle=\color{colString}, %
    commentstyle=\color{colComments}, %
    columns=flexible, %
    tabsize=2, %
    aboveskip={1.5\baselineskip}, %
    frame=single, %
    extendedchars=true, %
    showspaces=false, %
    showstringspaces=false, %
    numberstyle=\tiny, %
    breaklines=true, %
    backgroundcolor=, %
    breakautoindent=true, %
    captionpos=b%
}

% Algorithms
\usepackage[ruled, vlined, linesnumbered,algochapter,algo2e]{algorithm2e}

% Format page foot and header
\usepackage{scrpage2}
\clearscrheadings
\clearscrheadfoot
\automark[section]{chapter}
\ohead{\pagemark}
\ihead{\headmark}
\pagestyle{scrheadings}

%% use some standards for mathematical expressions:
\newcommand{\red}{{\rm red}}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}
% \newtheorem{definition}[theorem]{Definition}
\newtheorem{algorithm}[theorem]{Algorithm}
\newenvironment{example}{\begin{quote}{\bf Example:}}{\end{quote}}

% BIBTEX, http://merkel.zoneo.net/Latex/natbib.php
% if you uncomment this block, you'll get an english bibliography with alphanumerical references
%\usepackage{bibgerm} % u. a. statt et al
\usepackage[square,numbers]{natbib} % eckige klammern, natbib-package
% \setbibpreamble{{\large Seitenzahlen, auf denen ein Eintrag referenziert wird, werden am Ende eines jeden Eintrags angegeben.}\newline} % Wegen der pagebackref-Option des hyperref-Packets, wird vielen nicht direkt klar was das soll http://projekte.dante.de/DanteFAQ/Verzeichnisse#16

% gray definition boxes, that whay you'll find them in the text
\usepackage{shadethm}
\newshadetheorem{sthm}[figure]{Definition}
\newenvironment{definition}[1][]{
    \definecolor{shadethmcolor}{rgb}{.9,.9,.9}
    \begin{sthm}[#1]
    }{\end{sthm}}

% experimental
%\usepackage{scrhack}

% Hyperlinks and menu for your document
\usepackage[breaklinks,hyperindex,colorlinks,anchorcolor=black,citecolor=black,filecolor=black,linkcolor=black,menucolor=black,urlcolor=black,pdftex]{hyperref} % pagebackref: Add page number to the references where they can be found
% DO NOT LOAD ANY OF YOUR PACKAGES BEYOND THIS PACKAGE

\makeatletter
\AtBeginDocument{
    \hypersetup{
        pdftitle = {\@title},
        pdfauthor = {\@author},
        pdfsubject={\@title},
        pdfkeywords={SAML, add more}, % CHANGE HERE
        %    unicode={true},
    }
}
\makeatother

% Use the same counter for tables and figures
\makeatletter
\AtBeginDocument{
    \let\c@table\c@figure
    \let\c@lstlisting\c@table
    \let\c@algocf\c@lstlisting
}
\makeatother

\ifpdf
\hypersetup{linktocpage=false}  % false=links are section names, true=links are page numbers, IMPORTANT: in dvi2ps mode, 'true' is required!
\else
\hypersetup{linktocpage=true}       % false=links are section names, true=links are page numbers, IMPORTANT: in dvi2ps mode, 'true' is required!
\usepackage[hyphenbreaks]{breakurl}
\fi


%Customizing GanttChart
\definecolor{barblue}{RGB}{153,204,254}
\definecolor{groupblue}{RGB}{51,102,254}
\definecolor{linkred}{RGB}{165,0,33}
\renewcommand\sfdefault{phv}
\renewcommand\mddefault{mc}
\renewcommand\bfdefault{bc}
\setganttlinklabel{s-s}{START-TO-START}
\setganttlinklabel{f-s}{FINISH-TO-START}
\setganttlinklabel{f-f}{FINISH-TO-FINISH}
\sffamily
\ganttset
{%
    y unit chart=0.6cm,
    canvas/.append style={fill=none, draw=black!35, line width=.5pt},
    hgrid={*1{draw=black!35, line width=.1pt}},
    hgrid style/.style={draw=black!35,line width=.1pt},
    vgrid={*1{draw=black!35, line width=.1pt}},
    today rule/.style={draw=black!64,dash pattern=on 3.5pt off 4.5pt,line width=1.5pt},
    today label font=\small\bfseries,
    title/.style={draw=none, fill=none},
    title label font=\bfseries\footnotesize,
    title label node/.append style={below=7pt},
    progress label text={\pgfmathprintnumber[precision=0, verbatim]{#1}\%},
    include title in canvas=false,
    bar label font=\mdseries\small\color{black!70},
    bar label node/.append style={left=0cm},
    bar/.append style={draw=none, fill=black!63},
    bar incomplete/.append style={fill=barblue},
    bar progress label font=\mdseries\footnotesize\color{black!70},
    bar height=.8,
    bar top shift=0.1,
    group top shift=0.1,
    group incomplete/.append style={fill=groupblue},
    group left shift=0,
    group right shift=0,
    group height=.8,
    group peaks tip position=0,
    group label node/.append style={left=.6cm},
    group progress label font=\bfseries\small,
    link/.style={-latex, line width=1.5pt, linkred},
    link label font=\scriptsize\bfseries,
    link label node/.append style={below left=-2pt and 0pt}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% here your document starts
\begin{document}

%% switch to roman paginating for the acknowledgements, table of contents etc.
\pagenumbering{roman} % uncomment this if you like it

%% title page --- made out of expressions defined above
This is the front page

\pagenumbering{arabic} %switches to arabic numbers for the rest of the text
\setcounter{page}{1}

These are other pages

\textit{TESTTESTTESTTESTTEST}
{\itshape abcdefgh}
non-italic \emph{should be italic} itshape: {\itshape should be italic} 
textit: \textit{should be italic}

\pagestyle{scrplain} % turn off headers and footers

%\KOMAoptions{open=any} % Plaziert Kapitel auch auf linken Seiten

%% generate bibliography with bibtex, the bibfile here is "paper.bib"
\flushbottom
%\bibliographystyle{plainnat}
%\bibliography{literature/literature}

\end{document} 

--------------------更新二--------------------

我刚刚意识到,只要删除该部分,斜体就会起作用

\ganttset{[...]}

在我的 mwe 末尾。这是解决方案,但我有兴趣知道为什么会发生这种情况?有人可以解释一下吗?

谢谢

答案1

谢谢你的代码。以后,你最好删除序言的每一部分,同时仍然演示这个错误,并确保它能编译(所以它是一个最小在职的例如。)这对您和我们都有帮助:您实际上通过删除前言的不同部分自己找到了错误的位置。此外,\usepackage{protocol}其中有一个包不在 TeX Live 中,但您必须在自己的系统上安装它。这意味着我们无法测试您正在运行的相同代码,对我们有用的东西可能对您不起作用。

问题实际上出在以下几行之前\ganttset

\renewcommand\sfdefault{phv}
\renewcommand\mddefault{mc}
\renewcommand\bfdefault{bc}

这会尝试将 sans-serif 字体设置为使用旧版 Helvetica 的压缩版本,您可能实际上没有,但当时编写该模板的人确实有。它通过告诉 LaTeX 使用压缩系列来实现这一点全部字体。由于您实际使用的字体均没有中等压缩 ( mc) 或粗体压缩 ( bc) 系列,因此所有字体选择命令均会中断。

如果您检查文件中的错误消息.log,您可能会看到一些关于如何无法找到{T1}{lmr}{mc}{it},而是替换的消息{T1}{lmr}{m}{n}

删除这些命令。如果您确实想使用 Helvetica 的克隆而不是 Latin Modern Sans,而不是错误地复制和粘贴该代码,您可以\usepackage{tgheros}在后面添加\usepackage{lmodern}

还有一些其他过时的代码引起了我的注意。 \usepackage{scrpage2}应该是\usepackage{scrlayer-scrpage}\red命令应该定义为\textnormal{red}而不是{\rm red},你可能应该定义例子:作为备注,或者如果失败,{\normalfont\bfseries Example:}则不要使用\bf。您的序言中有一个\sffamily命令,但如果您确实想使用无衬线字体作为主字体,则应该使用\renewcommand{\familydefault}{\sfdefault}或者加载支持 的字体包[sfdefault]

这里最大的问题是,你似乎从别人的文档中复制了一堆你实际上不需要或不想要的旧代码。我建议你尝试尽可能多地注释掉这些代码,这样实际上才不会导致任何错误。

相关内容