
я используюмла13и 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}
Вот этот документ...
Ниже представлен документ без строки line \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}