我想在索引标题和内容之间写一些文字。(也在参考书目标题和内容之间写一些文字)。
我尝试过用文字重新定义标题,但希望有更好的解决办法,因为这太丑了。
谢谢。
答案1
鉴于性质的不同bibliography
,index
我将答案分为两部分:
书目标题和内容之间的文本。
该解决方案基于修补环境thebibliography
(使用包etoolbox
及其命令\patchcmd
)以便Some text
在内容之前添加。
\bibpreface{Text before bibliography}
我为其创建了一个命令。
这里有一个代码示例(包括.bib
使用filecontents
)
\documentclass{book}
%---------------------------------
% Database .bib file
\begin{filecontents}{mydatabib.bib}
@book{goossens93,
author = "Michel Goossens and Frank Mittlebach and Alexander Samarin",
title = "The Latex Companion",
year = "1993",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts"
}
@book{lamport94,
author = "Leslie Lamport",
title = "Latex: A Document Preparation System",
year = "1994",
edition = "Second",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts"
}
@misc{patashnik88,
author = "Oren Patashnik",
title = "{B}ib{T}e{X}ing. Documentation for General {B}ib{T}e{X} users",
year = "1988",
howpublished = "Electronic document accompanying BibTeX
distribution"
}
\end{filecontents}
%-----------------------------------------
\usepackage{etoolbox}
\newcommand{\bibpreface}[1]{\patchcmd{\thebibliography}{\list}{#1\list}{}{}}
\begin{document}
In \cite{goossens93} we can find information very useful about \LaTeX\ and in \cite{patashnik88} there is important information about \textsc{Bib}\TeX.
\nocite{*}
\bibpreface{Text before of bibliography, and some warnings to take in account when you read the books.}
\bibliographystyle{plain}
\bibliography{mydatabib}
\end{document}
部分结果(已剪辑)
这种方法也适用article
于report
类。
编辑
如果你写书目手动然后就这样
\documentclass{book}
\usepackage{etoolbox}
\newcommand{\bibpreface}[1]{\patchcmd{\thebibliography}{\list}{#1\list}{}{}}
\begin{document}
In \cite{goossens93} we can find information very useful about \LaTeX\ and in \cite{patashnik88} there is important information about \textsc{Bib}\TeX.
\nocite{*}
\bibpreface{Text before of bibliography, and some warnings to take in account when you read the books.
This allows change of lines.}
\begin{thebibliography}{1}
\bibitem{goossens93}
Michel Goossens, Frank Mittlebach, and Alexander Samarin.
\newblock {\em The Latex Companion}.
\newblock Addison-Wesley, Reading, Massachusetts, 1993.
\bibitem{lamport94}
Leslie Lamport.
\newblock {\em Latex: A Document Preparation System}.
\newblock Addison-Wesley, Reading, Massachusetts, second edition, 1994.
\bibitem{patashnik88}
Oren Patashnik.
\newblock {B}ib{T}e{X}ing. documentation for general {B}ib{T}e{X} users.
\newblock Electronic document accompanying BibTeX distribution, 1988.
\end{thebibliography}
\end{document}
您将获得期望的结果。
索引标题和内容之间的文本。
使用同样的想法我定义命令\indexpreamble{Text}
,这将写入他的文本跨越整个页面(记住index
写在 中twocolumn
)
您只需添加此代码前\makeindex
指令中的文件序言
\usepackage{etoolbox} %If it doesn't loaded
\newlength{\oldparindent}
\setlength{\oldparindent}{\parindent}
\newcommand{\indexpreamble}[1]{\patchcmd{\theindex}{]}{\setlength{\parindent}{\oldparindent}%
\noindent#1\par\indexspace]}{}{}}
\indexpreamble{...}
并在\printindex
(或) 之前使用\begin{theindex}
。
答案2
为什么不使用biblatex
?它功能丰富,而且不太复杂。我知道这不是您选择的软件包,但这里有一个建议:
-fieldprenote
只是为了满足你的目的而制作的(如果我理解正确的话):
\documentclass{article}
\usepackage{filecontents}
% suggested bibliography package
\usepackage[indexing = true]{biblatex}
\addbibresource{mydatabib.bib}
\defbibnote{bib-intro}{This is where you put your bibliography prenote.}
% suggested index package
\usepackage{imakeidx}
\makeindex
\begin{filecontents}{mydatabib.bib}
@book{goossens93,
author = "Michel Goossens and Frank Mittlebach and Alexander Samarin",
title = "The Latex Companion",
year = "1993",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts"
}
@misc{patashnik88,
author = "Oren Patashnik",
title = "{B}ib{T}e{X}ing. Documentation for General {B}ib{T}e{X} users",
year = "1988",
howpublished = "Electronic document accompanying BibTeX
distribution"
}
\end{filecontents}
\begin{document}
In \cite{goossens93} we can find information very useful about \LaTeX\ and in \cite{patashnik88} there is important information about \textsc{Bib}\TeX.
% Printing the bibliography
\printbibliography[prenote={bib-intro}]
% Printing the index with a prenote
\indexprologue{%
Index prenote goes here. Lets make it a bit longer just for illustrating the presentation of it.
}
\printindex
\end{document}
给我:
定义\printbibliography[prenote={bib-intro}]
要使用的预注,定义\defbibnote{bib-intro}{<text>}
要添加的文本。请参阅biblatex 文档。
请注意,我使用文章文档类而不是书籍仅用于说明目的(更容易将所有内容都放在一页上进行屏幕截图)。
我不太确定您想如何使用索引以及使用哪个包,但我会推荐imakeidx
。
通过包括
\usepackage{imakeidx}
\makeindex
在您的序言中,[indexing = true]
作为 biblatex 选项,您的书目数据已编入索引。我已将此设置添加到上面的示例中,这为我提供了以下索引: