\setlength\parindent{0.5in} 在我的文档中添加换行符

\setlength\parindent{0.5in} 在我的文档中添加换行符

我在用着mla13和 xelatex 创建 mla 格式的文档。我的教授要求我们的论文左对齐,所以我使用 \raggedright 来实现这一点。我发现这会导致段落缩进被删除,但由于 mla 格式的文档中段落需要缩进,所以我还必须使用 \setlength\parindent{0.5in} 重新设置它。我遇到的问题是这会导致在文档中添加换行符。

以下是一个例子:

\documentclass{article}
\usepackage{mla13}
\title{Sample Sources MLA13 Document}
\firstname{John}
\lastname{Smith}
\professor{Dr. Professor}
\class{FunClass}

\raggedright
\begin{document}
\makeheader
\setlength\parindent{0.5in}

In a recent report by the United Nations, they found that more than 884 million people do not have 
access to safe drinking water \cite[e.g.][15-23]{unWater}. This number equates to more than 1 out 
of every 8 people, not having access to something that is so vital to human life. Knowing this 
fact, most must ask themselves, why the same water that we drink is used to clean our toilets and 
wash our lawns. The water that hundreds of millions of people would love to have, is something that 
we just flush down the toilet. This paper intends to examine the benefits of grey water systems, 
and how their use leads to increased water conservation efforts, creating more benefits then costs.

Grey water systems are a technique that aids in water conservation efforts by reusing water that 
doesn't need to be fully cleaned. For example, many grey water systems use the water that comes 
from the shower drain to water the lawn or fill the toilet. Even though this water isn't going to a 
water treatment plant, doesn't mean that it is not clean. Grey water systems are equipped with a 
filter that removes most soaps and solid objects that make their way through the drainage system 
\cite{planetArk}. With a private market for greywater systems developing, there are a variety of 
commercial systems that filter water to ``remove hair, lint, and debris, and remove pollutants, 
bacteria, salts'' and many more materials \cite{pacificInst2010}

\end{document}

这是该文档的呈现形式...

带缩进的文档

下面是没有换行符的文档\setlength\parindent{0.5in}。请注意标题后面的换行符是如何消失的。知道是什么原因造成的吗?为了清楚起见,我想要实现的是段落缩进而不带额外的换行符。谢谢!

文档无缩进

答案1

%最简单的解决方案是在命令后添加一个\setlength。这样做的原因是缩进命令后的空白行被视为新段落,但在命令后被忽略\makeheader。尾随%有效地删除了空白行。有关详细信息,请参阅此问题。

\documentclass{article}
\usepackage{mla13}
\title{Sample Sources MLA13 Document}
\firstname{John}
\lastname{Smith}
\professor{Dr. Professor}
\class{FunClass}
\raggedright


\begin{document}
\makeheader
\setlength\parindent{0.5in}%

In a recent report by the United Nations, they found that more than 884 million people do not have 
access to safe drinking water \cite[e.g.][15-23]{unWater}. This number equates to more than 1 out 
of every 8 people, not having access to something that is so vital to human life. Knowing this 
fact, most must ask themselves, why the same water that we drink is used to clean our toilets and 
wash our lawns. The water that hundreds of millions of people would love to have, is something that 
we just flush down the toilet. This paper intends to examine the benefits of grey water systems, 
and how their use leads to increased water conservation efforts, creating more benefits then costs.

Grey water systems are a technique that aids in water conservation efforts by reusing water that 
doesn't need to be fully cleaned. For example, many grey water systems use the water that comes 
from the shower drain to water the lawn or fill the toilet. Even though this water isn't going to a 
water treatment plant, doesn't mean that it is not clean. Grey water systems are equipped with a 
filter that removes most soaps and solid objects that make their way through the drainage system 
\cite{planetArk}. With a private market for greywater systems developing, there are a variety of 
commercial systems that filter water to ``remove hair, lint, and debris, and remove pollutants, 
bacteria, salts'' and many more materials \cite{pacificInst2010}

\end{document}

输出

答案2

添加\setlength\parindent{0.5in}于其所属的位置,即之前\begin{document}

\documentclass{article}
\usepackage{mla13}
\title{Sample Sources MLA13 Document}
\firstname{John}
\lastname{Smith}
\professor{Dr. Professor}
\class{FunClass}

\raggedright
\setlength\parindent{0.5in}

\begin{document}
\makeheader

In a recent report by the United Nations, they found that more than 884 million people do not have 
access to safe drinking water \cite[e.g.][15-23]{unWater}. This number equates to more than 1 out 
of every 8 people, not having access to something that is so vital to human life. Knowing this 
fact, most must ask themselves, why the same water that we drink is used to clean our toilets and 
wash our lawns. The water that hundreds of millions of people would love to have, is something that 
we just flush down the toilet. This paper intends to examine the benefits of grey water systems, 
and how their use leads to increased water conservation efforts, creating more benefits then costs.

Grey water systems are a technique that aids in water conservation efforts by reusing water that 
doesn't need to be fully cleaned. For example, many grey water systems use the water that comes 
from the shower drain to water the lawn or fill the toilet. Even though this water isn't going to a 
water treatment plant, doesn't mean that it is not clean. Grey water systems are equipped with a 
filter that removes most soaps and solid objects that make their way through the drainage system 
\cite{planetArk}. With a private market for greywater systems developing, there are a variety of 
commercial systems that filter water to ``remove hair, lint, and debris, and remove pollutants, 
bacteria, salts'' and many more materials \cite{pacificInst2010}

\end{document}

在此处输入图片描述

看到这可耻的排版,我的眼睛都红了。

为什么要添加一个空行?嗯,\makeheader命令以 结尾\end{nospacecenter},其定义为

\newenvironment{nospacecenter}
  {\parskip=0pt\par\nopagebreak\centering}
  {\par\noindent\ignorespacesafterend}

\makeheader因此 TeX 在完成其工作后会排版一个新段落。

当然,删除\noindent\ignorespacesafterend才是正确的定义:

\newenvironment{nospacecenter}
  {\parskip=0pt\par\nopagebreak\centering}
  {\par}

更好的定义是

\newenvironment{nospacecenter}
  {\parskip=0pt\topsep=0pt \trivlist\listparindnt=0pt \item\relax\centering}
  {\endtrivlist}

这样,后面有空行\end{nospacecenter}就会增加缩进,没有空行则不会。

还应\makeheader修复:

\newcommand*{\makeheader}{%
  \begingroup
  \parindent\z@
  \rmfamily
  \@firstname\ \@lastname\\
  \@professor\\
  \@class\\
  \datef\@date
  \begin{nospacecenter}
  \@title
  \end{nospacecenter}
  \endgroup
}

这是一个完整的示例,包含一些变化(我还添加了一个nospacecenter用于测试它的环境):

\documentclass{article}
\usepackage{mla13}
\title{Sample Sources MLA13 Document}
\firstname{John}
\lastname{Smith}
\professor{Dr. Professor}
\class{FunClass}

% Fix some wrong bits in mla13.sty
\makeatletter
\renewcommand*{\makeheader}{%
  \begingroup
  \parindent\z@
  \rmfamily
  \@firstname\ \@lastname\\
  \@professor\\
  \@class\\
  \datef\@date
  \begin{nospacecenter}
  \@title
  \end{nospacecenter}
  \endgroup
}
\renewenvironment{nospacecenter}
  {\parskip=\z@\topsep=\z@\trivlist\listparindent\z@
  \item\relax\centering}
  {\endtrivlist}
\makeatletter

\raggedright
\setlength\parindent{0.5in}

\begin{document}
\makeheader

In a recent report by the United Nations, they found that more than 884 million people do not have 
access to safe drinking water \cite[e.g.][15-23]{unWater}. This number equates to more than 1 out 
of every 8 people, not having access to something that is so vital to human life. Knowing this 
fact, most must ask themselves, why the same water that we drink is used to clean our toilets and 
wash our lawns. The water that hundreds of millions of people would love to have, is something that 
we just flush down the toilet. This paper intends to examine the benefits of grey water systems, 
and how their use leads to increased water conservation efforts, creating more benefits then costs.
\begin{nospacecenter}
abc
\end{nospacecenter}
Grey water systems are a technique that aids in water conservation efforts by reusing water that 
doesn't need to be fully cleaned. For example, many grey water systems use the water that comes 
from the shower drain to water the lawn or fill the toilet. Even though this water isn't going to a 
water treatment plant, doesn't mean that it is not clean. Grey water systems are equipped with a 
filter that removes most soaps and solid objects that make their way through the drainage system 
\cite{planetArk}. With a private market for greywater systems developing, there are a variety of 
commercial systems that filter water to ``remove hair, lint, and debris, and remove pollutants, 
bacteria, salts'' and many more materials \cite{pacificInst2010}

\end{document}

在此处输入图片描述

相关内容