缩进除第一行以外的所有行,并且右对齐

缩进除第一行以外的所有行,并且右对齐
a line of text\\
and another one\\
\indent line that should be indented \\
and this one should not be\\
\indent but this should

在我向序言中添加 \raggedright 之前,此方法一直有效。关于类似问题的帖子有很多,但当我尝试给出的解决方案时,我得到的段落中每行都缩进。我是否遗漏了什么?本质上,我试图用以下代码重现以下布局

\subsection{Light}
\textit{Evocation cantrip}\\
\textbf{Casting Time:} 1 action\\
\textbf{Range:} Touch\\
\textbf{Components:} V, M (a firefly or phosphorescent moss)\\
\textbf{Duration:} 1 hour\\
You touch one object that is no larger than 10 feet in any dimension. Until the spell ends, the object sheds bright light in a 20-foot radius and dim light for an additional 20 feet. The light can be colored as you like. Completely covering the object with something opaque blocks the light. The spell ends if you cast it again or dismiss it as an action. \\
\indent If you target an object held or worn by a hostile creature, that creature must succeed on a Dexterity saving throw to avoid the spell.

但是当我在序言中添加 \raggedright 时,缩进就消失了。有没有办法在任意行中添加缩进,同时仍然保留不规则的右边缘?

在此处输入图片描述

答案1

这里有两种快捷方法(请参阅下文了解更好的方法):

  1. \hspace{1em}\\

  2. 最好使用段落结构,而不是\\一般使用。然后您可以设置\parindent缩进值。

妇女权利委员会:

\documentclass{article}
\raggedright
\begin{document}
\subsection{Light}
\textit{Evocation cantrip}\\
\textbf{Casting Time:} 1 action\\
\textbf{Range:} Touch\\
\textbf{Components:} V, M (a firefly or phosphorescent moss)\\
\textbf{Duration:} 1 hour\\
You touch one object that is no larger than 10 feet in any dimension. Until the spell ends, the object sheds bright light in a 20-foot radius and dim light for an additional 20 feet. The light can be colored as you like. Completely covering the object with something opaque blocks the light. The spell ends if you cast it again or dismiss it as an action. \\
\hspace{1em}%
If you target an object held or worn by a hostile creature, that creature must succeed on a Dexterity saving throw to avoid the spell.

\subsection{Light}
\textit{Evocation cantrip}\\
\textbf{Casting Time:} 1 action\\
\textbf{Range:} Touch\\
\textbf{Components:} V, M (a firefly or phosphorescent moss)\\
\textbf{Duration:} 1 hour\\
You touch one object that is no larger than 10 feet in any dimension. Until the spell ends, the object sheds bright light in a 20-foot radius and dim light for an additional 20 feet. The light can be colored as you like. Completely covering the object with something opaque blocks the light. The spell ends if you cast it again or dismiss it as an action. \par
\parindent=1em%
If you target an object held or worn by a hostile creature, that creature must succeed on a Dexterity saving throw to avoid the spell.
\end{document}

在此处输入图片描述

这两种快速修复方法的问题在于,通常来说,它们\\是一种非常糟糕且不推荐的格式化行的方法。第二种\par方法的问题是,每个新子节都必须包含\noindent所有标题信息,一旦将\parindent其设置为非零值。所以我认为第三种方法最好...

更好的方法是将其融入宏结构中,并\par始终使用该方法(已编辑以允许多行标题信息):

\documentclass{article}
\usepackage[usestackEOL]{stackengine}
\raggedright
\strutlongstacks{T}
\newcommand\mysubsection[6]{%
\subsection{#1}
\setstackgap{S}{0pt}%
\Shortstack[l]{%
\parbox{\linewidth}{\strut\textit{#2}\strut}\\
\parbox{\linewidth}{\strut\textbf{Casting Time:} #3}\\
\parbox{\linewidth}{\strut\textbf{Range:} #4\strut}\\
\parbox{\linewidth}{\strut\textbf{Components:} #5\strut}\\
\parbox{\linewidth}{\strut\textbf{Duration:} #6}}%
\par\noindent\ignorespaces%
}
\parindent=1em%

\begin{document}

\mysubsection{Light}{Evocation cantrip}{1 action}{Touch}
  {V, M a firefly or phosphorescent moss) with
  a multi-line item tha goes blah blah blah blah}{1 hour}
%
You touch one object that is no larger than 10 feet in any dimension. Until the 
spell ends, the object sheds bright light in a 20-foot radius and dim light 
for an additional 20 feet. The light can be colored as you like. Completely 
covering the object with something opaque blocks the light. The spell ends 
if you cast it again or dismiss it as an action. 

If you target an object held or worn by a hostile creature, that creature 
must succeed on a Dexterity saving throw to avoid the spell.
\end{document}

在此处输入图片描述

答案2

通常来说\RaggedRightfrom比长期不整齐的右侧排版ragged2e更好。\raggedright

它还允许指定父母。

\documentclass{article}
\usepackage{ragged2e}

\newcommand{\manualsection}[3]{%
  % #1 = title
  % #2 = subtitle
  % #3 = items
  \subsection[#1]{%
    \parbox{\columnwidth}{
      #1\\
      \normalfont\normalsize
      \textit{#2}\\[\smallskipamount]
      #3%
    }%
  }%
}
\newcommand{\secitem}[2]{%
  \textbf{#1:} #2%
}

\setcounter{secnumdepth}{1} % only number sections
\setlength{\RaggedRightParindent}{\parindent}
\RaggedRight


\begin{document}

\manualsection{Light}{Evocation cantrip}
  {\secitem{Casting Time}{1 action}\\
   \secitem{Range}{Touch}\\
   \secitem{Components}{V, M (a firefly or phosphorescent moss)}\\
   \secitem{Duration}{1 hour}}

You touch one object that is no larger than 10 feet in any dimension.
Until the spell ends, the object sheds bright light in a 20-foot
radius and dim light for an additional 20 feet. The light can be
colored as you like. Completely covering the object with something
opaque blocks the light. The spell ends if you cast it again or
dismiss it as an action.

If you target an object held or worn by a hostile creature, that
creature must succeed on a Dexterity saving throw to avoid the spell.

\end{document}

在此处输入图片描述

相关内容