有条件生成文本块

有条件生成文本块

在当前使用 xelatex、回忆录类的文档中,我的章节是诗歌评论块的汇编。请参阅附加代码。[粗体文本使用不同的语言,衬线文本是英文对应文本]

有没有办法分离诗句部分,当我编译时,文档只生成诗句列表,如果我更改 tex 序言中的标志,我就可以生成诗句和随附的评论文本块。


\documentclass[12pt]{memoir}
\usepackage{lipsum}
\usepackage{polyglossia} % the multilingual support package

\setromanfont[Ligatures=TeX]{Linux Libertine O}
\def\mverse{\ifhmode \par \fi
   \goodbreak \addvspace{3ex} \refstepcounter{section}
   \centerline{\textbf{Verse \arabic{section}}}\medskip}

\newenvironment{customtext}%
  {\leftskip=1em \rightskip=1em }%
  {\ifhmode \par \fi}
\newcommand\mstyle[1]{\begin{customtext}\setlength{\parindent}{0pt}{\large
    \textbf{#1}} \\
    {\sffamily #1}\end{customtext}\medskip}

\begin{document}

\mverse
\mstyle{This is a custom verse}
\lipsum

The old fox jumps over the lazy dog.
The old fox jumps over the lazy dog.
The old fox jumps over the lazy dog.
The old fox jumps over the lazy dog.
The old fox jumps over the lazy dog.
The old fox jumps over the lazy dog.
The old fox jumps over the lazy dog.
The old fox jumps over the lazy dog.
The old fox jumps over the lazy dog.

\mverse
\mstyle{This is verse 2}

The old fox jumps over the lazy dog.
The old fox jumps over the lazy dog.
The old fox jumps over the lazy dog.
The old fox jumps over the lazy dog.
The old fox jumps over the lazy dog.
The old fox jumps over the lazy dog.
The old fox jumps over the lazy dog.
The old fox jumps over the lazy dog.
The old fox jumps over the lazy dog.
The old fox jumps over the lazy dog.
The old fox jumps over the lazy dog.

\end{document}

我看了两者LaTeX 条件表达式以及如何根据 documentclass 选项有条件地执行某些操作?但我的情况有所不同。 在此处输入图片描述

相关内容