如何阻止首字下沉出现在连续的段落中?

如何阻止首字下沉出现在连续的段落中?

我正在写一篇论文,在开始章节的第一段使用首字下沉看起来很有吸引力。我正在使用在 Overleaf 中找到的论文模板,使用lettrine首字下沉包。第一段的首字下沉对齐正确。但是,缩进也出现在连续的段落中。阻止这种情况出现在不同的段落中会很有帮助。

代码:

\documentclass{book}
\usepackage{ragged2e}
\usepackage{fancyhdr}
\usepackage{setspace}

\usepackage{type1cm}
\usepackage{lettrine}
\setlength{\DefaultNindent}{0pt}
\setlength{\DefaultFindent}{3pt}
\setcounter{DefaultLines}{2} 
\renewcommand{\LettrineTextFont}{\rmfamily}
\renewcommand{\LettrineFontHook}{\fontfamily{ptm}}

\begin{document}
\chapter{Introduction} % Main chapter title

\label{Chapter1}
\doublespacing
%\lhead{Chapter 1. \emph{Introduction}}
%%%%-------------------Fancy Head & Footer---------
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[C]{\thepage}
\fancyhead[LE,RO]{Chapter 1. \emph{Introduction}}
%%%%-------------------%%%%%%%%%%%%%%%-------------
% Change X to a consecutive number; this is for the header on each page - perhaps a shortened title

%----------------------------------------------------------------------------------------
%   SECTION 1
%----------------------------------------------------------------------------------------

\section{Background}
\begin{justify}

\lettrine[loversize=0.15]{M}{emory} devices came a long way starting from punched cards in 1890 A.D. which could hold approximately 80 B (Bytes) of data, to the present day greater than 2 TB (Terabyte) memory space in USB flash drives. In the present era of the Internet of Things (IoT), people are surrounded by different sensory devices in their daily lives. These devices generate enormous amounts of data giving rise to the concept of BIG DATA in IoT \cite{Ch1_ref1}. For efficient management of such data, the requirement of an intelligent computing architecture having reliable and high-density data storage memory devices for faster and reliable data processing is of immense importance for the current and upcoming future generations \cite{Ch1_ref2}.

Currently, the memory market is dominated by DRAM and flash memory devices. To meet the growing demand in terms of read/write speed and integration density, devices are scaled aggressively, which sets limits \cite{Ch1_ref3,Ch1_ref4,Ch1_ref5} to the above devices. 2D NAND devices have been scaled down to a 15 nm technology node, further scaling sets several limitations on the device. Vertical NAND (V-NAND) or 3D NAND with a stacked structure addresses this scalability issue \cite{Ch1_ref6} and provides greater storage density. However, such devices suffer from low read-write cycles and costly fabrication methodology, making them unsuitable for applications requiring faster data processing at affordable pricing.

\end{justify}
\end{document}

输出:

在此处输入图片描述

他们使用以下命令来停止连续段落中的字母包:

%********STOP LETTERING PACKAGE****************%
\section*{}
\parshape=0
\vspace{-25mm}
%***********************************************%

还有其他选项可以停止 lettrine 包吗?

答案1

正如@egreg在评论中所说,您不应该重新定义每个章节的页眉。相反,您应该使用LaTeX的标记机制来设置自动标记并在页眉中使用它们。

\doublespacing也不需要多次使用。在下面的例子中,我只对整个文档使用setspace了 的选项doublespacing。如果您希望某些部分(例如目录)不使用双倍行距,那么有时在\singlespacing和之间切换确实很有意义\doublespacing。但在这种情况下,在序言中进行适当的配置是理想的。

最后但并非最不重要的一点是,您不需要\begin{justify}…\end{justifiy}对整个文档或章节使用对齐。对齐是 LaTeX 的默认设置,因此根本不需要它。您不应使用此环境来对齐文本,而应限制不使用对齐,例如,使用组或环境。删除justify也可以解决您的问题。现在,只使用通常的段落缩进。如果您也不想要默认的段落缩进,请参见例如包裹parskip寻找替代方案。

\documentclass{book}

\usepackage{fancyhdr}
\usepackage[doublespacing]{setspace}

\usepackage{type1cm}
\usepackage{lettrine}
\setlength{\DefaultNindent}{0pt}
\setlength{\DefaultFindent}{3pt}
\setcounter{DefaultLines}{2} 
\renewcommand{\LettrineTextFont}{\rmfamily}
\renewcommand{\LettrineFontHook}{\fontfamily{ptm}}

% Define the page style once and use automatic marks
\fancyhf{}
\fancyfoot[C]{\thepage}
\fancyhead[LE,RO]{\nouppercase\leftmark}
\makeatletter
\renewcommand*{\chaptermark}[1]{\markboth{\ifnum\c@chapter>\z@ \@chapapp~\thechapter. \fi\textit{#1}}{}}
\makeatother
\renewcommand*{\sectionmark}[1]{}
\pagestyle{fancy}

\begin{document}
\chapter{Introduction} % Main chapter title

\label{Chapter1}
%\doublespacing

% ----------------------------------------------------------------------------------------
%   SECTION 1
%----------------------------------------------------------------------------------------

\section{Background}

\lettrine[loversize=0.15]{M}{emory} devices came a long way starting from punched cards in 1890 A.D. which could hold approximately 80 B (Bytes) of data, to the present day greater than 2 TB (Terabyte) memory space in USB flash drives. In the present era of the Internet of Things (IoT), people are surrounded by different sensory devices in their daily lives. These devices generate enormous amounts of data giving rise to the concept of BIG DATA in IoT \cite{Ch1_ref1}. For efficient management of such data, the requirement of an intelligent computing architecture having reliable and high-density data storage memory devices for faster and reliable data processing is of immense importance for the current and upcoming future generations \cite{Ch1_ref2}.

Currently, the memory market is dominated by DRAM and flash memory devices. To meet the growing demand in terms of read/write speed and integration density, devices are scaled aggressively, which sets limits \cite{Ch1_ref3,Ch1_ref4,Ch1_ref5} to the above devices. 2D NAND devices have been scaled down to a 15 nm technology node, further scaling sets several limitations on the device. Vertical NAND (V-NAND) or 3D NAND with a stacked structure addresses this scalability issue \cite{Ch1_ref6} and provides greater storage density. However, such devices suffer from low read-write cycles and costly fabrication methodology, making them unsuitable for applications requiring faster data processing at affordable pricing.

\end{document}

在此处输入图片描述

相关内容