![如何讓下一段不縮排? (`\noindent`僅適用於本段)](https://rvso.com/image/420769/%E5%A6%82%E4%BD%95%E8%AE%93%E4%B8%8B%E4%B8%80%E6%AE%B5%E4%B8%8D%E7%B8%AE%E6%8E%92%EF%BC%9F%20%EF%BC%88%60%5Cnoindent%60%E5%83%85%E9%81%A9%E7%94%A8%E6%96%BC%E6%9C%AC%E6%AE%B5%EF%BC%89.png)
我想為以日期開頭的部分類型建立一個巨集。我已經走到這一步了:
\documentclass[a5paper, 11pt]{memoir}
\usepackage{ebgaramond}
\usepackage{lipsum}
\setsecheadstyle{\Large\scshape\memRTLraggedright}
\newcommand{\dateSection}[2]{\section*{#1}{\vspace{-1\baselineskip}\hfill \small #2}\noindent}
\begin{document}
\dateSection{Lorem ipsum}{Monday Mars 21}
\lipsum[1-2]
\end{document}
但我在它後面有一個縮進,並且\noindent
我添加的內容對我沒有幫助。
我該怎麼做才能在巨集中解決這個問題?
答案1
設定下一個段落以吞噬縮排框。
\documentclass[a5paper, 11pt]{memoir}
\usepackage{ebgaramond}
\usepackage{lipsum}
\setsecheadstyle{\Large\scshape\memRTLraggedright}
\makeatletter
\newcommand{\dateSection}[2]{%
\section*{#1}%
{\vspace{-1\baselineskip}\hfill \small #2\par\nobreak}%
\@afterindentfalse % don't indent the next paragraph
\@afterheading % don't break pages too early
}
\makeatother
\begin{document}
\dateSection{Lorem ipsum}{Monday Mars 21}
\lipsum[1-2]
\end{document}
這樣,命令後面是否有空行都無關緊要\dateSection
。
下一段至少有兩行以及章節標題和日期。
答案2
\raisebox
在巨集定義中新增:
\documentclass[a5paper, 11pt]{memoir}
\usepackage{ebgaramond}
\usepackage{lipsum}
\setsecheadstyle{\Large\scshape\memRTLraggedright}
\newcommand{\dateSection}[2]{\section*{#1\hfill\raisebox{-0.6\baselineskip}[0pt][0pt]{\upshape\small#2}}}
\begin{document}
\dateSection{Lorem ipsum}{Monday Mars 21}
\lipsum[1-2]
\end{document}