\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}

所以 TeX 在\makeheader完成工作後正在排版一個新段落。

當然,刪除\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}

在此輸入影像描述

相關內容