我会写一篇诗集,由多位作者撰写。我希望每位作者都在纯文本文件中写一首诗。
到目前为止,我写了一个主文件诗书.tex
\documentclass{article}
\begin{document}
\input{Poetry/FirstPoetry.txt}
\end{document}
和第一首诗歌.txt
\title{theTitle}
\author{theAuthor}
\date{theDate}
\maketitle
\begin{verbatim}
it is first line
it is second line
\end{verbatim}
如何简化文本文件的编写,尽量减少格式FirstPoetryRev.txt
theTitle
theAuthor
theDate
it is first line
it is second line
然后诗书.tex会翻译
- 作为
first line
the title
- 作为
second line
the author
- 作为
third line
the date
- 和 (
space
) - as
fifth line and so on
,the content of the poem
无需\\
在每行末尾书写。
答案1
\documentclass{article}
\usepackage{fancyvrb}
\begin{document}
\renewcommand{\FancyVerbFormatLine}[1]{%
\ifcase\value{FancyVerbLine}\or
\makebox[\textwidth]{\huge#1\strut}\or
\makebox[\textwidth]{\LARGE#1\strut}\or
\makebox[\textwidth]{\Large#1}\else#1\fi}
\VerbatimInput{file}
\end{document}
编辑目录添加
\documentclass{article}
\usepackage{fancyvrb}
\begin{document}
\tableofcontents
\renewcommand{\FancyVerbFormatLine}[1]{%
\ifcase\value{FancyVerbLine}\or
\makebox[\textwidth]{\xdef\mttitle{#1}\huge#1\strut}\or
\makebox[\textwidth]{\addcontentsline{toc}{section}{\mttitle\ by #1}\LARGE#1\strut}\or
\makebox[\textwidth]{\Large#1}\else#1\fi}
\VerbatimInput{file}
\newpage
\VerbatimInput{file1}
\end{document}
答案2
为了完整性,我将在这里添加我的解决方案。
我使用 memoir 作为类和 verse 以及 gmverse 包。Gmverse 很棒,它能给你:
- 每首诗自动居中(无需输入最长的一行并计算其长度)
- 如果是每节,则每行末尾(但不是最后一行)不需要 \。这使得从电子邮件或文本、word 等文件进行复制和粘贴变得更加容易。
然后我使用 subfiles 包,其作用类似于包括但每个子文件还知道主要 doc 文件的名称,并且可以读取序言(在 \begin{document} 之前),因此可以独立编译。这使得编辑、汇编和创建多个集合(即期刊投稿)比一个大文件更简单。它还可以使单个诗歌模板保持相当小。重新排序也更容易。
所以我为每首诗重复使用一个模板(在 Mac 上,您可以在信息面板中将文件设置为文具,然后双击将获得该文件的新副本)并根据需要重命名它们。
单首诗模板:
\documentclass[older_poems_40.tex]{subfiles}
\begin{document}
\vocweigh3 %needed for gmverse package, must be here not
% in preamble
\thispagestyle{empty} %remove before using as subfile
\PoemTitle{TITLE} %%%% this will be numbered * version is not numbered
%\epigraph{}{}
\begin{verse}
\index{FIRST_LINE}FIRST_line of poem
line 2
line 3
new stanza 1
line 2
\end{verse}
\end{document}
主文件当然包含大量格式化内容,因此我将在此添加一个截断版本。(但请注意,我保留了诗歌列表(内容)以及首行索引(这需要您在添加新子文件后重新运行 make index),以供您参考。
%file = older_poems_40.tex
\documentclass[12pt, twoside]{memoir}
%\usepackage[utf8]{inputenc} % I use Xetex so I don't need this anymore
\usepackage{epigraph}
% set a note, subtitle quote or source under the poem title
\setlength{\epigraphwidth}{.45\textwidth} % Was 0.4
\usepackage{makeidx}
\makeindex
\usepackage{verse, gmverse}
\usepackage{currfile} %% to get a compile date for records/sanity
\usepackage{hyperref}
\renewcommand{\PoemTitlefont}{\Large\slshape\centering}
\title{Your poetry book name here}
\author{Your name here!}
\date{}
\hypersetup{
pdftitle={poems of blah},
pdfsubject={blah},
pdfauthor={David J. Garbutt},
pdfkeywords={poetry}
}
% or set to blank for anonymous submissions
\usepackage{subfiles}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%. DOCUMENT%%%%%%%%%%%%%%
\begin{document}
\maketitle
\epigraph{street }{town, postcode, country}
\clearpage
\tableofcontents
\vfill
Compiled from \texttt{\currfilepath} on \today{}.
\clearpage
\subfile{poem1}
\clearpage
\subfile{poem2} %.tex is assumed
%% repeat lots of poems…
%% here I have clear pages only in the master file this makes it easier
%% to create a more compact version if wanted.
%%%%% end poems
\renewcommand\indexname{Index of First Lines}
\onecolindex
\printindex
\end{document}
您必须确保单首诗歌模板中指向的文件是包含子文件语句的文件!