如何右對齊文字區塊的最後一行?

如何右對齊文字區塊的最後一行?

我用來pandoc將 Markdown 文件轉換為 LaTeX 文檔,然後轉換為 PDF。我的文件包含一些引文。它們來自標準 Markdown,呈現為LaTeX 文件quotationquote在 LaTeX 文件中呈現。

Markdown 不可能明確指出引文的簽名或來源。因此,我無法使用類似的套件attrib來以不同的方式設定歸因部分的樣式。

問題:如何右對齊報價的簽名?更一般地說,如何右邊刷新區塊的最後一行?或者,以“--”開頭的行可以右對齊嗎? (這三個中任何一個都可以。)

這是一個最小的 LaTeX 文檔,它顯示了我的意圖。我希望將“-- Walt Disney”部分向右移動。

\documentclass{book}
\setlength{\parindent}{0em} % Added for clarity.
\renewcommand{\quote}{\list{}{\itshape}\item\relax} % Making quote italic.
\begin{document}
\begin{quote}
The way to get started is to quit talking and begin doing.

-- Walt Disney
\end{quote}
\end{document}

不,使用像dirtytalkcsquotes、 或 這樣的包epigraph是行不通的。 Markdown 的來源不會(也不能)區分引用和歸屬。都是一個quote街區。

答案1

在我看來,您似乎希望Markdown獲得一種新的報價。你說“這不是 Markdown 文件包含樣式/渲染命令的想法”,但它確實如此——它支援規範斜體大膽的字體。

關於 LaTeX,這裡有一個聲明 ( \justlastragged),它將把段落的最後一行設為右對齊。

% lastraggedprob.tex  SE 641048

\documentclass{article}

\newcommand{\paratext}{Just some text to fill up a couple of lines,
  which might be used for a paragraph or
  some other kind of text block. Let's hope it works out.}

\begin{document}

\newcommand{\justlastragged}{%
  \leftskip =0pt plus 1fil
  \rightskip =-\leftskip
  \parfillskip=\leftskip
% \parindent = 0pt
}
  
\section{First}

Normal paragraph setting

\paratext

\paratext

\section{Second}

Last line of a paragraph being set flush right (ragged left).
\justlastragged

\paratext

\paratext

\paratext \paratext

\end{document}

在此輸入影像描述

\justlastragged聲明是我在 2007 年在 TUGboat 中描述的不同樣式段落的幾種設定之一https://tug.org/TUGboat/tb28-2/tb89glister.pdf

答案2

嘗試使用\hfill來填滿先前的水平空間-- Walt Disney

\documentclass{book}
\setlength{\parindent}{0em} % Added for clarity.
\renewcommand{\quote}{\list{}{\itshape}\item\relax} % Making quote italic.
\begin{document}
\begin{quote}
The way to get started is to quit talking and begin doing.

\hfill -- Walt Disney
\end{quote}
\end{document}

是的,\hfill只要 pandoc 輸出 LaTeX 或在後端使用 LaTeX 來產生 PDF,它就會被處理。

> The way to get started is to quit talking and begin doing.
> 
> \hfill -- Walt Disney

潘多克輸出

(由 pandoc 產生的圖像;如果您希望它像 LaTeX 程式碼一樣為斜體,當然,您必須在 markdown 文件或 pandoc 的選項中添加更多內容,但我猜您已經知道如何做到這一點了?)

相關內容