我正在尝试更新帕帕文第六版(由于我不是真正的 latex 黑客,所以这是一项艰巨的任务),我想强制某些级别的标题符合标题大小写。这是每一个word 为大写。例如:
- 大写 = 成年初期社会转型延迟
- 小写=成年初期社会转型延迟
- 句子形式 = 成年初期社会转型延迟
- 标题案例 = 成年初期社会转型延迟
我的问题是:
- 是否有一种我还没找到的简单方法可以做到这一点?
- 有人可以告诉我需要知道什么才能自己实现这个目标吗?
谢谢大家。
附言:我知道这篇文章与标签“案例”无关,但我无法创建新标签,因为我的声誉不够,而且没有其他合适的标签:(
答案1
这段代码应该可以帮助您入门。它使用了软件包的几个stringstrings
字符串处理例程,包括识别您希望以小写形式排版的单词,这非常耗时\addlcwords
。其余代码将其挂接到 APA 的分段命令中(这很繁琐,但确实有效)。
请注意,虽然这应该可以让您开始,但它还没有完全准备好迎接黄金时段,主要是因为这项工作需要一些时间,如果这不是您想要继续进行的事情,就会分散我对我实际上应该做的事情的注意力:)
。尽管如此,如果您想要继续进行这项工作,您需要让大家stringstrings
知道“-”(如“Knock-on”)应与空格字符一样处理(运行下面的代码以了解我的意思)。这项工作可能涉及将“-”交给stringstrings
命令\encodetoken
并提供一些额外的支持代码——尽管如果有几种方法可以解决这一问题,我不会感到惊讶。
无论如何,尽管还有一些工作要做,但我希望它能带你朝着你想要的方向前进。(注意:不要忘记:stringstrings
似乎会随\addlcwords
时间呈指数级增长。或者更糟。)
\documentclass[jou]{apa}
\usepackage{lipsum}
\usepackage{stringstrings}
\addlcwords{all of the and a an is before on}
\DeclareRobustCommand*\MakeTitlecase[1]{%
\caselower[e]{#1}%
\capitalizetitle{\thestring}%
}
\makeatletter
% Four Levels with Sections in Title Case
\def\FourLevelHeadingTitleCase{%
\def\section{\@ifnextchar*{\@sections}%
{\@ifnextchar[{\@sectionb}{\@section}}}%
\def\@sections*##1{\leveltwo{\MakeTitlecase{##1}}}%
\def\@sectionb[##1]##2{\leveltwo{\MakeTitlecase{##2}}%
\@mkboth{\MakeUppercase{##1}}{\MakeUppercase{##1}}%
\addcontentsline{toc}{section}{\MakeTitlecase{##1}}}%
\def\@section##1{\leveltwo{\MakeTitlecase{##1}}%
\@mkboth{\MakeUppercase{##1}}{\MakeUppercase{##1}}%
\addcontentsline{toc}{section}{\MakeTitlecase{##1}}}%
%
\def\subsection{\@ifnextchar*{\@subsections}%
{\@ifnextchar[{\@subsectionb}{\@subsection}}}%
\def\@subsections*##1{\levelthree{\MakeTitlecase{##1}}}%
\def\@subsectionb[##1]##2{\levelthree{\MakeTitlecase{##2}}%
\addcontentsline{toc}{subsection}{\MakeTitlecase{##1}}}%
\def\@subsection##1{\levelthree{\MakeTitlecase{##1}}%
\addcontentsline{toc}{subsection}{\MakeTitlecase{##1}}}%
%
\def\subsubsection{\@ifnextchar*{\@subsubsections}%
{\@ifnextchar[{\@subsubsectionb}{\@subsubsection}}}%
\def\@subsubsections*##1{\levelfour{\MakeTitlecase{##1}}}%
\def\@subsubsectionb[##1]##2{\levelfour{\MakeTitlecase{##2}}%
\addcontentsline{toc}{subsubsection}{\MakeTitlecase{##1}}}%
\def\@subsubsection##1{\levelfour{\MakeTitlecase{##1}}%
\addcontentsline{toc}{subsubsection}{\MakeTitlecase{##1}}}%
%
\let\paragraph=\levelfive%
}
\makeatother
\FourLevelHeadingTitleCase
\title{On the Bodleianisation of L-Space Interior Topologies}
\author{The Librarian}
\affiliation{Unseen University}
\shorttitle{Ook}
\rightheader{Oook}
\leftheader{Capitalised Headers}
\abstract{\lipsum[1]}
\begin{document}
\maketitle
\section{Library-Space is NOT countable}
\lipsum[1]
\subsection{Turtles ALL the way down}
\lipsum[2]
\subsubsection{On THE Knock-ON Effect oN wood}
\lipsum[3]
\subsubsection{an orang And a utan}
\lipsum[3]
\end{document}
答案2
该titlecaps
包 (http://ctan.org/pkg/titlecaps(但请注意,CTAN 的缺陷在于它不会显示在搜索中,但实际上存在)可以做到这一点。在编写了“极其耗时”的 stringstrings 包(正如 Geoffrey 正确指出的那样)之后,我努力为标题的情况做得更好。这个titlecaps
包就是结果。
文档中的一个示例显示了如何完全小写源:
\documentclass{article}
\usepackage{titlecaps}
\parskip 1em
\parindent 0em
\def\bs{$\backslash$}
\begin{document}
\Resetlcwords
\Addlcwords{for a is but and with of in as the etc on to if}
\titlecap{%
to know that none of the words typed in this paragraph were initially
upper cased might be of interest to you. it is done to demonstrate the
behavioral features of this package. first, you should know the words
that i have pre-designated as lower case. they are: ``for a is but and
with of in as the etc on to if.'' you can define your own list. note
that punctuation, like the period following the word ``if'' did not mess
up the search for lower case (nor did the quotation marks just now).
punctuation which is screened out of the lower-cased word search pattern
include . , : ; ( ) [ ] ? ! ` ' however, I cannot screen text braces;
\{for example in\} is titled, versus (for example in), since the braces
are not screened out in the search for pre-designated lower-case words
like for and in. However, \texttt{\bs textnc} provides a workaround:
\{\textnc{for example in}\}. titlecap will consider capitalizing
following a (, [, \{, or - symbol, such as (abc-def). you can use your
text\textit{\relax xx} commands, like i just did here with the prior xx,
but if you want the argument of that command to not be titled, you
either need, in this example, to add \textit{xx} to the lowercase word
list, which you can see i did not. instead, i put ``\bs relax~xx'' as
the argument, so that, in essence, the \bs relax was capitalized, not
the x. Or you could use \texttt{\bs textnc} . here i demonstrate that
text boldface, \textbf{as in the \bs textbf command}, also works fine,
as do \texttt{texttt}, \textsl{textsl}, \textsc{textsc},
\textsf{textsf}, \textit{etc}. titlecap will work on diacritical marks,
such as \"apfel, \c cacao \textit{etc.}, \scriptsize fontsize \LARGE
changing commands\normalsize\unskip, as well as national symbols such as
\o laf, \ae gis, and \oe dipus. unfortunately, i could not get it to
work on the \aa~nor the \l~symbols. the method will work with some
things in math mode, capitalizing symbols if there is a leading space,
$x^2$ can become $ x^2$, and it can process but it will not capitalize
the greek symbols, such as $\alpha$, and will choke on most macros, if
they are not direct character expansions. Additionally,
\textsf{titlecaps} also works with font changing declarations, for
example, \bs itshape\bs sffamily. \itshape\sffamily you can see that it
works fine. likewise, any subsequent \bs textxx command will, upon
completion, return the font to its prior state, such as this
\textbf{textbf of some text}. you can see that i have returned to the
prior font, which was italic sans-serif. now I will return to upright
roman\upshape\rmfamily. a condition that will not behave well is inner
braces, such as \ttfamily \bs titlecap\{blah \{inner brace material\}
blah-blah\}. \rmfamily see the section on quirks and limitations for a
workaround involving \texttt{\bs textnc}. titlecap will always
capitalize the first word of the argument (\textbf{even if it is on the
lower-case word list}), unless \texttt{\bs titlecap} is invoked with an
optional argument that is anything other than a capital p. in that case,
the first word will be titled \textit{unless} it is on the lowercase
word list. for example, i will do a \bs titlecap[\relax s]\{\relax
a~big~man\} and get ``\titlecap[s]\textnc{a big man}'' with the ``a''
not titled. i hope this package is useful to you, but as far as using
\textsf{titlecaps} on such large paragraphs\ldots \textbf{do not try
this at home!}}
\end{document}
只需几秒钟的执行时间就可以变成这样: