我想使用由等宽字符构建的图形作为 acmart 文档中的预告图。在文档的其他地方,我使用表格内的逐字部分来实现这一点,创建由横跨页面宽度的字符组成的图形。acmart 格式使得在作者行和摘要之间放置任何内容变得困难,但是,我尝试放置在那里的任何内容都会被放置在文档开头的单独页面上,然后才会出现其他内容。
查看 acmart.cls 类文件,我发现插入预告图部分是通过以下几行实现的:
\def\@teaserfigures{}
\newenvironment{teaserfigure}{\Collect@Body\@saveteaser}{}
\long\def\@saveteaser#1{\g@addto@macro\@teaserfigures{\@teaser{#1}}}
有没有办法将任意内容(例如逐字)放入此区域?也可能有其他选项,例如以某种方式将逐字放在作者列表末尾,只要它出现在作者列表和正文之间即可。我专门使用 Xetex。
下面是包含有效 teaser 的示例 acmart 文档的代码。有效 teaserfigure 规范下方是注释规范,表达了我想要的内容:包含逐字的 teaserfigure。尝试注释掉有效 teaser 并启用包含逐字的 teaserfigure,您会发现尝试生成它将失败。
以下代码的摘要依赖于名为“sampleteaser.pdf”的图像,它是此 zip 文件内的 /samples 文件夹中提供的 ACM 示例内容的一部分:ACM 模板文件
\documentclass[sigplan,screen]{acmart}
\usepackage[utf8]{inputenc}
\usepackage{fontspec}
\usepackage{subcaption}
\usepackage{setspace}
\setcopyright{acmcopyright}
\copyrightyear{2023}
\acmYear{2023}
\acmDOI{XXXXXXX.XXXXXXX}
\acmConference[Conference]{Full Conference Name}{Date of}{Location}
\acmPrice{0.00}
\begin{document}
\title{Title}
\subtitle{And a subtitle}
\author{Author Name}
\email{[email protected]}
\begin{abstract}
Abstract goes here.
\end{abstract}
\keywords{keywords, go, here}
%% A "teaser" image appears between the author and affiliation
%% information and the body of the document, and typically spans the
%% page.
%% This teaser works:
\begin{teaserfigure}
\includegraphics[width=\textwidth]{sampleteaser}
\caption{Seattle Mariners at Spring Training, 2010.}
\Description{Enjoying the baseball game from the third-base
seats. Ichiro Suzuki preparing to bat.}
\label{fig:teaser}
\end{teaserfigure}
%% This teaser is broken:
%% \begin{teaserfigure}
%% \begin{verbatim}
%% abc
%% def
%% \end{verbatim}
%% \end{teaserfigure}
%%
%% This command processes the author and affiliation and title
%% information and builds the first part of the formatted document.
\maketitle
\section{Introduction}
Intro goes here.
%% Here's a working verbatim as part of the article text:
\begin{verbatim}
abc
def
\end{verbatim}
\section{Conclusion}
Another section.
\end{document}
\endinput
后续问题:如何将样式应用于花哨的逐字部分?我正在尝试这个:
\setlength{\lineskiplimit}{\maxdimen}
\setlength{\lineskip}{-0.1pt}
\begin{SaveVerbatim}[fontsize=6pt]{TeaserVerb}
content
goes
here
\end{SaveVerbatim}
\begin{teaserfigure}
\UseVerbatim{TeaserVerb}
\end{teaserfigure}
\setlength{\lineskiplimit}{0pt}
\setlength{\lineskip}{1pt}
但它不起作用。需要更改换行符,因为我在部分内使用了方框绘制字符;不应该有任何换行符,这样行之间就不会出现断行。我还在其中设置了字体大小,也尝试了 fontsize=small,但这也没有带来任何变化。
答案1
您可以使用SaveVerbatim
来自fancyvrb
。
\documentclass[sigplan,screen]{acmart}
%\usepackage[utf8]{inputenc} % <--- NOT with fontspec
\usepackage{fontspec}
\usepackage{subcaption}
%\usepackage{setspace} % <--- ? Why?
\usepackage{fancyvrb} % <--- For SaveVerbatim
\setcopyright{acmcopyright}
\copyrightyear{2023}
\acmYear{2023}
\acmDOI{XXXXXXX.XXXXXXX}
\acmConference[Conference]{Full Conference Name}{Date of}{Location}
\acmPrice{0.00}
\begin{document}
\title{Title}
\subtitle{And a subtitle}
\author{Author Name}
\email{[email protected]}
\begin{abstract}
Abstract goes here.
\end{abstract}
\keywords{keywords, go, here}
%% A "teaser" image appears between the author and affiliation
%% information and the body of the document, and typically spans the
%% page.
\begin{SaveVerbatim}{TeaserVerb}
abc \LaTeX is {} nice
def
\end{SaveVerbatim}
\begin{teaserfigure}
\UseVerbatim{TeaserVerb}
\end{teaserfigure}
\maketitle
\section{Introduction}
Intro goes here.
%% Here's a working verbatim as part of the article text:
\begin{verbatim}
abc
def
\end{verbatim}
\section{Conclusion}
Another section.
\end{document}
inputenc
如果您打算使用 LuaLaTeX 或 XeLaTeX(和) ,请不要加载fontspec
。顺便说一句,几年来utf8
这也是默认设置。pdflatex
我不会setspace
加载acmart
。
请注意,逐字模式尊重行上的初始空格,如示例所示(参见正文verbatim
)。
编辑
\lineskiplimit
如何进行特殊格式化?这是一种可行的方法,可以保留和本地的设置\lineskip
。
\documentclass[sigplan,screen]{acmart}
%\usepackage[utf8]{inputenc} % <--- NOT with fontspec
\usepackage{fontspec}
\usepackage{subcaption}
%\usepackage{setspace} % <--- ? Why?
\usepackage{fancyvrb} % <--- For SaveVerbatim
\newsavebox{\verbteaserbox}
\setcopyright{acmcopyright}
\copyrightyear{2023}
\acmYear{2023}
\acmDOI{XXXXXXX.XXXXXXX}
\acmConference[Conference]{Full Conference Name}{Date of}{Location}
\acmPrice{0.00}
\begin{document}
\title{Title}
\subtitle{And a subtitle}
\author{Author Name}
\email{[email protected]}
\begin{abstract}
Abstract goes here.
\end{abstract}
\keywords{keywords, go, here}
%% A "teaser" image appears between the author and affiliation
%% information and the body of the document, and typically spans the
%% page.
\setbox\verbteaserbox=\vbox{
\setlength{\lineskiplimit}{\maxdimen}%
\setlength{\lineskip}{0pt}%
\setlength{\parindent}{0pt}%
\fontsize{6}{0}\selectfont
\begin{BVerbatim}
abc \LaTeX is {} nice
def
abc \LaTeX is {} nice
def
abc \LaTeX is {} nice
def
abc \LaTeX is {} nice
def
abc \LaTeX is {} nice
def
\end{BVerbatim}
}
\begin{teaserfigure}
\usebox{\verbteaserbox}
\end{teaserfigure}
\maketitle
\section{Introduction}
Intro goes here.
%% Here's a working verbatim as part of the article text:
\begin{verbatim}
abc
def
\end{verbatim}
\section{Conclusion}
Another section.
\end{document}