| 1 |
% \iffalse meta-comment |
| 2 |
% ========================================================================== |
| 3 |
% luabibentry.dtx v0.1a, 2012/02/02 |
| 4 |
% Copyright (c) Oliver Kopp, 2012 |
| 5 |
% |
| 6 |
% This file is part of the LuaLaTex package `luabibentry'. |
| 7 |
% |
| 8 |
% This work may be distributed and/or modified under the conditions of |
| 9 |
% the LaTeX Project Public License, version 1.3c of the license. |
| 10 |
% The latest version of this license is in |
| 11 |
% http://www.latex-project.org/lppl.txt |
| 12 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 13 |
% version 2005/12/01 or later. |
| 14 |
% |
| 15 |
% This work has the LPPL maintenance status "maintained". |
| 16 |
% |
| 17 |
% The Current Maintainer and author of this work is Oliver Kopp. |
| 18 |
% |
| 19 |
% This work consists of the files `luabibentry.dtx' and `README'. |
| 20 |
% |
| 21 |
% Unpacking: |
| 22 |
% tex luabibentry.dtx |
| 23 |
% Documentation: |
| 24 |
% pdflatex luacode.dtx |
| 25 |
% ========================================================================== |
| 26 |
% |
| 27 |
%<*ignore> |
| 28 |
\begingroup |
| 29 |
\def\x{LaTeX2e}% |
| 30 |
\expandafter\endgroup |
| 31 |
\ifcase 0\ifx\install y1\fi\expandafter |
| 32 |
\ifx\csname processbatchFile\endcsname\relax\else1\fi |
| 33 |
\ifx\fmtname\x\else 1\fi\relax |
| 34 |
\else\csname fi\endcsname |
| 35 |
%</ignore> |
| 36 |
%<*install> |
| 37 |
\input docstrip.tex |
| 38 |
\keepsilent |
| 39 |
\askforoverwritefalse |
| 40 |
{ |
| 41 |
\obeyspaces\obeylines |
| 42 |
\global\def\preambletext{ |
| 43 |
\space |
| 44 |
Copyright (c) 2012 by Oliver Kopp <oliver.kopp.googlemail.com> |
| 45 |
|
| 46 |
This file was generated from file(s) of luabibentry distribution. |
| 47 |
----------------------------------------------------------------- |
| 48 |
|
| 49 |
This work may be distributed and/or modified under the conditions of |
| 50 |
the LaTeX Project Public License, version 1.3c of the license. |
| 51 |
The latest version of this license is in |
| 52 |
http://www.latex-project.org/lppl.txt |
| 53 |
and version 1.3c or later is part of all distributions of LaTeX |
| 54 |
version 2005/12/01 or later. |
| 55 |
|
| 56 |
This work has the LPPL maintenance status "maintained". |
| 57 |
|
| 58 |
The Current Maintainer and author of this work is Oliver Kopp. |
| 59 |
|
| 60 |
This file may only be distributed together with the files listed in |
| 61 |
`luabibentry.dtx'. You may however distribute the files listed in |
| 62 |
`luabibentry.dtx' without this file. |
| 63 |
} |
| 64 |
\global\def\stypreambletext{ |
| 65 |
\preambletext |
| 66 |
Usage: |
| 67 |
|
| 68 |
\string\setupbibentry{<bibliography>} before the usage of \string\bibentry. |
| 69 |
\string\setupbibentry{\string\jobname} may be used if the bibliography has the same name as the .tex file. |
| 70 |
|
| 71 |
\string\bibentry{<entry>} where you want to have placed an entry. |
| 72 |
In case an entry is not found "?" is output |
| 73 |
} |
| 74 |
} |
| 75 |
% |
| 76 |
\expandafter\preamble |
| 77 |
\preambletext |
| 78 |
\endpreamble |
| 79 |
% |
| 80 |
\declarepreamble\stypreamble |
| 81 |
\stypreambletext |
| 82 |
\endpreamble |
| 83 |
% |
| 84 |
\def\BibTeXComment{@Comment } |
| 85 |
\let\MetaPrefix\BibTeXComment |
| 86 |
\declarepreamble\bibpreamble |
| 87 |
\preambletext |
| 88 |
\endpreamble |
| 89 |
% |
| 90 |
\def\ThreeHyphens{---} |
| 91 |
\let\MetaPrefix\ThreeHyphens |
| 92 |
% |
| 93 |
\expandafter\declarepreamble\expandafter\luapreamble |
| 94 |
\preambletext |
| 95 |
\endpreamble |
| 96 |
|
| 97 |
\generate{% |
| 98 |
\let\MetaPrefix\DoubleperCent |
| 99 |
\usepreamble\defaultpreamble |
| 100 |
\file{test-luabibentry.tex}{\from{luabibentry.dtx}{testlatex}}% |
| 101 |
% |
| 102 |
\let\MetaPrefix\DoubleperCent |
| 103 |
\usepreamble\stypreamble |
| 104 |
\file{luabibentry.sty}{\from{luabibentry.dtx}{package}}% |
| 105 |
% |
| 106 |
\let\MetaPrefix\BibTeXComment |
| 107 |
\usepreamble\bibpreamble |
| 108 |
\nopostamble |
| 109 |
\file{test-luabibentry.bib}{\from{luabibentry.dtx}{testbibtex}}% |
| 110 |
% |
| 111 |
\let\MetaPrefix\ThreeHyphens |
| 112 |
\usepreamble\luapreamble |
| 113 |
\nopostamble |
| 114 |
\file{luabibentry.lua}{\from{luabibentry.dtx}{lua}}% |
| 115 |
} |
| 116 |
{ |
| 117 |
\obeyspaces |
| 118 |
\Msg{************************************************************************} |
| 119 |
\Msg{*} |
| 120 |
\Msg{* To finish the installation you have to move the following} |
| 121 |
\Msg{* files into a directory searched by TeX:} |
| 122 |
\Msg{*} |
| 123 |
\Msg{* luabibentry.sty and luabibentry.lua} |
| 124 |
\Msg{*} |
| 125 |
\Msg{* Happy TeXing!} |
| 126 |
\Msg{*} |
| 127 |
\Msg{************************************************************************} |
| 128 |
} |
| 129 |
|
| 130 |
%\csname endinput\endcsname |
| 131 |
\endbatchfile |
| 132 |
%</install> |
| 133 |
%<package>\NeedsTeXFormat{LaTeX2e}[1995/06/01] |
| 134 |
%<package>\ProvidesPackage{luabibentry} |
| 135 |
%<driver>\ProvidesFile{luaindex.dtx} |
| 136 |
%<*driver|package> |
| 137 |
[2012/02/02 v0.1a LuaLaTeX Package to place bibliography entries in text] |
| 138 |
%</driver|package> |
| 139 |
%<lua>if (luatexbase and (luatexbase.provides_module)) then |
| 140 |
%<lua> luatexbase.provides_module({ |
| 141 |
%<lua> name = "luabibentry", |
| 142 |
%<lua> date = "2012/02/02", |
| 143 |
%<lua> version = "0.1a", |
| 144 |
%<lua> description = "LuaLaTeX Package to Place Bibliography Entries in Text", |
| 145 |
%<lua> author = "Oliver Kopp", |
| 146 |
%<lua> licence = "LPPL v1.3c or later" |
| 147 |
%<lua> }) |
| 148 |
%<lua>end |
| 149 |
%<*ignore> |
| 150 |
\fi |
| 151 |
%</ignore> |
| 152 |
%<*driver> |
| 153 |
\documentclass[oneside,DIV=16,BCOR=0cm,parskip=half]{scrdoc} |
| 154 |
\usepackage[english]{babel} |
| 155 |
\usepackage{hyperref} |
| 156 |
\providecommand*{\LuaLaTeX}{Lua\kern-.025em\LaTeX} |
| 157 |
\CodelineIndex |
| 158 |
\RecordChanges |
| 159 |
\GetFileInfo{luabibentry.ltx} |
| 160 |
\title{% |
| 161 |
The \texttt{luabibentry} package |
| 162 |
} |
| 163 |
%\date{\fileversion} %currently doesn't work |
| 164 |
\date{Version 0.1a as of 2012/02/02} |
| 165 |
\author{Oliver Kopp\thanks{oliver.kopp% |
| 166 |
@% |
| 167 |
googlemail% |
| 168 |
.% |
| 169 |
com}} |
| 170 |
\begin{document} |
| 171 |
\maketitle |
| 172 |
\DocInput{luabibentry.dtx} |
| 173 |
\end{document} |
| 174 |
%</driver> |
| 175 |
%\fi^^A meta-comment |
| 176 |
% |
| 177 |
% \changes{v0.1}{2011/06/27}{start of new package} |
| 178 |
% \changes{v0.1a}{2012/02/02}{fixed lua code to use `require' instead of `dofile'.} |
| 179 |
% |
| 180 |
% \begin{abstract} |
| 181 |
% Typically, bibliographic entries are put at the end of a document. This |
| 182 |
% package allows for \emph{repeating} bibliographic entries in the document itself. The package |
| 183 |
% is inspired by bibentry, which provides similar functionality for \LaTeX{}. |
| 184 |
% \end{abstract} |
| 185 |
% |
| 186 |
% \tableofcontents |
| 187 |
% |
| 188 |
% \section{Introduction} |
| 189 |
% This package allows one to place bibliographic entries anywhere |
| 190 |
% in the text. It is to be used to produce annotated bibliographies, such as |
| 191 |
% \begin{quote} |
| 192 |
% For an intoduction to the topic of workflow management, see |
| 193 |
% Frank Leymann and Dieter Roller. {\it Production Workflow -- Concepts and Techniques}. |
| 194 |
% Prentice Hall PTR, 2000. |
| 195 |
% \end{quote} |
| 196 |
% |
| 197 |
% The idea is that the full reference is used, not just the citation [1] or |
| 198 |
% Leymann and Roller [2000]. |
| 199 |
% |
| 200 |
% This package is a variant of bibentry.sty by Patrick W.\ Daly. bibentry.sty is |
| 201 |
% distributed with the natbib |
| 202 |
% package\footnote{\url{http://mirror.ctan.org/macros/latex/contrib/natbib/}}. This |
| 203 |
% documentation of luabibentry is mostly adapted from Patrick's documentation of |
| 204 |
% bibentry. bibentry itself is part of the natbib package. |
| 205 |
% |
| 206 |
% The main reason for the reimplementation is the incompatibility of hyperref's |
| 207 |
% backref with bibenetry.sty. The \texttt{\textbackslash saved \makeatletter |
| 208 |
% @\makeatother bibitem} solution did not work here. |
| 209 |
% |
| 210 |
% The differences to bibentry.sty is: |
| 211 |
% The commands |\nobibliography| and |\nobibliography*| |
| 212 |
% are unsupported. luabibentry always uses the bibliography of the |
| 213 |
% document. |
| 214 |
% |
| 215 |
% \section{Usage} |
| 216 |
% |\setupbibentry{<bibliography>}| before the usage of |\bibentry|.\\ |
| 217 |
% |\setupbibentry{\jobname}| may be used if the bibliography has the same name as the |.tex| file. |
| 218 |
% |
| 219 |
% |\bibentry{<entry>}| where you want to have placed an entry. |
| 220 |
% In case an entry is not found, ``?'' is output. |
| 221 |
% |
| 222 |
% \section{Caveats} |
| 223 |
% The caveats of the entry format are similar to the bibentry package. The only |
| 224 |
% difference is that luabibentry expects the key as last token in the bibitem entry. |
| 225 |
% Thus, the following text is a verbatim copy of bibentry's documentation with the |
| 226 |
% reference to the allowed space after the key being removed. |
| 227 |
% |
| 228 |
% The entries in the \texttt{.bbl} must be of the form |
| 229 |
% \begin{quote} |
| 230 |
% |\bibitem|\oarg{label}\marg{key}\\ |
| 231 |
% \emph{Text of the reference entry.}\\[1ex] |
| 232 |
% |\bibitem|\dots |
| 233 |
% \end{quote} |
| 234 |
% That is, there must be a new line after the \marg{key} |
| 235 |
% and a blank line before the next |\bibitem|. The final period in the text |
| 236 |
% will be removed, if present, allowing one to place the |\bibentry| commands |
| 237 |
% in mid-sentence. Of course, there may be other periods within the text that |
| 238 |
% might look funny. |
| 239 |
% |
| 240 |
% \section{Test} |
| 241 |
% A simple test whether luabibentry runs is provided here: |
| 242 |
% |
| 243 |
% \iffalse meta-comment |
| 244 |
%<*testlatex> |
| 245 |
% \fi |
| 246 |
% \begin{macrocode} |
| 247 |
\documentclass{article} |
| 248 |
\usepackage{luabibentry} |
| 249 |
\setupbibentry{\jobname} |
| 250 |
|
| 251 |
\usepackage[backref=page]{hyperref} |
| 252 |
|
| 253 |
\begin{document} |
| 254 |
|
| 255 |
The entry for \cite{LR2000} is: \bibentry{LR2000}. |
| 256 |
|
| 257 |
\bibliographystyle{plain} |
| 258 |
\bibliography{test-luabibentry} |
| 259 |
|
| 260 |
\end{document} |
| 261 |
% \end{macrocode} |
| 262 |
% \iffalse meta-comment |
| 263 |
%</testlatex> |
| 264 |
% \fi |
| 265 |
% |
| 266 |
% \iffalse meta-comment |
| 267 |
%<*testbibtex> |
| 268 |
% \fi |
| 269 |
% \begin{macrocode} |
| 270 |
@BOOK{LR2000, |
| 271 |
title = {{P}roduction {W}orkflow -- {C}oncepts and {T}echniques}, |
| 272 |
publisher = {Prentice Hall PTR}, |
| 273 |
year = {2000}, |
| 274 |
author = {Frank Leymann and Dieter Roller}, |
| 275 |
isbn = {0130217530} |
| 276 |
} |
| 277 |
% \end{macrocode} |
| 278 |
% \iffalse meta-comment |
| 279 |
%</testbibtex> |
| 280 |
% \fi |
| 281 |
% |
| 282 |
% \section{Implementation of Lua Module \texttt{luabibentry.lua}} |
| 283 |
% \iffalse meta-comment |
| 284 |
%<*lua> |
| 285 |
% \fi^^A meta-comment |
| 286 |
% \begin{macrocode} |
| 287 |
module("luabibentry", package.seeall) |
| 288 |
require("lualibs-file") |
| 289 |
|
| 290 |
-- stores all entries |
| 291 |
local entries = {} |
| 292 |
|
| 293 |
-- builds the data by reading the given filename |
| 294 |
function builddata(filename) |
| 295 |
-- Parameters seem to be passed as arrays. |
| 296 |
-- We access the first element of the parameter to get the filename |
| 297 |
local file = io.open(filename[1], "r") |
| 298 |
if file==nil then |
| 299 |
texio.write_nl("luabibentry: could not open file " .. filename[1]) |
| 300 |
return |
| 301 |
end |
| 302 |
local line = file:read("*line") |
| 303 |
while (line~=nil) do |
| 304 |
-- \bibitem is our marker for new entries |
| 305 |
local i = string.find(line, "\\bibitem") |
| 306 |
if i~=nil then |
| 307 |
-- we expect the key in brackets in the same line |
| 308 |
i = string.find(line,"{") |
| 309 |
local lasti = 0 |
| 310 |
-- we jump to the last bracket |
| 311 |
while i~= nil do |
| 312 |
lasti = i |
| 313 |
i = string.find(line,"{",i+1) |
| 314 |
end |
| 315 |
local key = string.sub(line, lasti+1) |
| 316 |
-- we use the text from the last opening bracket ("{") until |
| 317 |
-- the end of the line minus one |
| 318 |
-- we expect nothing more to follow in this line |
| 319 |
key = string.sub(key, 1, string.len(key)-1) |
| 320 |
-- the next lines are the entry |
| 321 |
-- we expect an entry to be finished with a blank line |
| 322 |
-- (or the end of the file) |
| 323 |
line = file:read("*line") |
| 324 |
local entry = "" |
| 325 |
while (line~=nil) and (line~="") do |
| 326 |
entry = entry .. line |
| 327 |
line = file:read("*line") |
| 328 |
end |
| 329 |
-- remove the final dot (if present) |
| 330 |
local entryLen = string.len(entry) |
| 331 |
local lastChar = string.sub(entry, entryLen, entryLen) |
| 332 |
if lastChar == "." then |
| 333 |
entry = string.sub(entry, 1, entryLen-1) |
| 334 |
end |
| 335 |
entries[key]=entry |
| 336 |
end |
| 337 |
line = file:read("*line") |
| 338 |
end |
| 339 |
file:close() |
| 340 |
end |
| 341 |
|
| 342 |
-- looks up the given key in the entries |
| 343 |
-- in case an entry is not found, a bold question mark is printed |
| 344 |
function bibentry(key) |
| 345 |
local res = entries[key[1]] |
| 346 |
if res==nil then |
| 347 |
res = "\\textbf{?}" |
| 348 |
end |
| 349 |
tex.print(res) |
| 350 |
end |
| 351 |
|
| 352 |
% \end{macrocode} |
| 353 |
% |
| 354 |
% \iffalse meta-comment |
| 355 |
%</lua> |
| 356 |
% \fi^^A meta-comment |
| 357 |
|
| 358 |
% \section{Implementation of \LaTeX{} Package \texttt{luabibentry.sty}} |
| 359 |
% |
| 360 |
% \iffalse meta-comment |
| 361 |
%<*package> |
| 362 |
% \fi^^A meta-comment |
| 363 |
% \LuaLaTeX{} must be used to use the package. |
| 364 |
% \begin{macrocode} |
| 365 |
\RequirePackage{ifluatex} |
| 366 |
\ifluatex\else |
| 367 |
\PackageError{luabibentry}{lualatex needed}{% |
| 368 |
Package `luabibentry' needs LuaTeX.\MessageBreak |
| 369 |
So you should use `lualatex' to process you document!\MessageBreak |
| 370 |
See documentation of `luabibentry' for further information.}% |
| 371 |
\expandafter\expandafter\expandafter\csname endinput\endcsname |
| 372 |
\fi |
| 373 |
% \end{macrocode} |
| 374 |
% |
| 375 |
% Load the lua module: |
| 376 |
% \begin{macrocode} |
| 377 |
\directlua{require("luabibentry.lua")} |
| 378 |
% \end{macrocode} |
| 379 |
% |
| 380 |
% Interface to the lua module: |
| 381 |
% \begin{macrocode} |
| 382 |
\newcommand{\setupbibentry}[1]{\directlua{luabibentry.builddata{"#1.bbl"}}} |
| 383 |
\newcommand{\bibentry}[1]{\nocite{#1}\directlua{luabibentry.bibentry{"#1"}}} |
| 384 |
% \end{macrocode} |
| 385 |
% |
| 386 |
% \iffalse meta-comment |
| 387 |
%</package> |
| 388 |
% \fi^^A meta-comment |
| 389 |
% |
| 390 |
% \section{Acknowledgements} |
| 391 |
% This package is a variant of |bibentry.sty| by Patrick W.\ Daly. |bibentry.sty| is |
| 392 |
% distributed with the |natbib| package. This documentation of luabibentry is |
| 393 |
% mostly adapted from Patrick's documentation of |bibentry|. |
| 394 |
% |
| 395 |
% Thanks to Markus Kohm for the dtx and lua inspirements, Manuel |
| 396 |
% P\'egouri\'e-Gonnard for the Makefile, dtx, and lua inspirements, and |
| 397 |
% Heiko Oberdiek for his detailed feedback on a draft version of this package. |
| 398 |
% |
| 399 |
% \Finale |
| 400 |
% |
| 401 |
\endinput |