En la web de las III Jornadas de usuarios de R ya está disponible el Libro de Resúmenes. Incluye más de 40 comunicaciones organizadas en 5 mesas.
Cada autor proponía su comunicación a través de un formulario en la web que se convertía en un mensaje de correo dirigido al comité científico (ejemplo). Con R transformamos cada uno de estos textos en un fichero LaTeX. La función que lo consigue es:
txt2tex <- function(file, memoir=TRUE){
txt <- readLines(file)
txt <- gsub('[[:space:]]+$', '', txt) ##elimino los espacios finales
nombreIdx <- which(txt=='Se ha recibido exitosamente la solicitud de participación de')+1
nombre <- txt[nombreIdx]
nombreCompleto <- strsplit(nombre, ' ')[[1]]
nombrePila <- nombreCompleto[1]
apellidos <- paste(nombreCompleto[-1], collapse=' ')
correo <- txt[nombreIdx+2]
inst <- txt[nombreIdx+4]
tituloIdx <- which(txt=='El título de la comunicación es:')+1
titulo <- txt[tituloIdx]
nombreFile <- gsub('[[:space:][:punct:]]', '_', titulo)
##elimino caracteres extraños en nombre de ficheros
nombreFile <- iconv(nombreFile, 'UTF-8', 'ASCII//TRANSLIT')
nombreFile <- tolower(nombreFile)
nombreTex <- paste(nombreFile, '.tex', sep='')
nombreBib <- paste(nombreFile, '.bib', sep='')
sep <- '---------------------------------------------'
sepIdx <- which(txt==sep)
resumen <- paste(txt[(sepIdx[1]+1):(sepIdx[2]-2)], collapse='\n')
biblio <- txt[seq((sepIdx[3]+1), (sepIdx[4]-2), 1)]
notas <- paste('%', txt[seq((sepIdx[5]+1), length(txt))], collapse='\n')
clase <- '\\documentclass{article}'
preambulo <- paste('\\usepackage[utf8]{inputenc}',
'\\usepackage[spanish]{babel}',
'\\usepackage{url}',
sep='\n'
)
fecha <- '\\date{}'
if (memoir) {
titulo <- paste('\\chapter{', titulo, '}', sep='')
autor <- paste('\\chapterprecis{', nombre,
'\\\\', inst, '}',
sep='')
autorIdx <- paste('\\index{', paste(apellidos, nombrePila, sep=', '), '}', sep='')
} else {
titulo <- paste('\\title{', titulo, '}', sep='')
autor <- paste('\\author{', nombre,
'\\\\', inst, '}',
sep='')
}
maketitle <- '\\maketitle'
inicio <- '\\begin{document}'
fin <- '\\end{document}'
bibliografia <- paste('\\bibliography{', nombreFile, '}', sep='')
bibstyle <- '\\bibliographystyle{flexbib}'
if (memoir){
txt <- paste(titulo,
autor, notas, autorIdx,
resumen,
bibstyle,
bibliografia,
sep='\n\n')
} else {
txt <- paste(clase, preambulo, inicio,
titulo,
autor, notas,
fecha,
maketitle,
resumen,
bibstyle,
bibliografia,
fin, sep='\n\n')
}
writeLines(txt, nombreTex)
writeLines(biblio, nombreBib)
txt
}
El resultado es un fichero tex (al que hay que añadir manualmente una línea con \index[inst]{Afiliación}) y otro bibtex.
A continuación, cada uno de estos ficheros se integra en el libro usando el paquete memoir y la orden \include de LaTeX:
\documentclass[a4paper, 12pt]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm}
\pagestyle{Ruled}
\usepackage{array}
\usepackage{verbatim}
\usepackage{prettyref}
\usepackage{booktabs}
\usepackage{textcomp}
\usepackage{url}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage[spanish]{babel}
\addto\shorthandsspanish{\spanishdeactivate{~<>}}
\usepackage{mathpazo}%Letra palatino con fuentes para matemáticas
\usepackage{amsfonts}
\usepackage{memhfixc}
\usepackage{mempatch}
\raggedbottom
\sloppybottom
\clubpenalty=10000
\widowpenalty=10000
\newcommand{\HRule}{\rule{\linewidth}{0.7mm}}
\pretitle{\vfill \begin{center} \HRule \par \bfseries \scshape \HUGE}
\posttitle{\HRule \par\end{center}}
\preauthor{\begin{center} \large \scshape}
\postauthor{\par\end{center}}
\predate{\vfill \begin{center}\large\scshape}
\postdate{\par\end{center}\vfill}
\openany
\chapterstyle{southall}
\makepagestyle{index}
\makeheadrule{index}{\textwidth}{\normalrulethickness}
\makeevenhead{index}{\rightmark}{}{\leftmark}
\makeoddhead{index}{\rightmark}{}{\leftmark}
\makeevenfoot{index}{\thepage}{}{}
\makeoddfoot{index}{}{}{\thepage}
\makeindex
\makeindex[inst]
\usepackage{hyperref}
\hypersetup{
bookmarks=true, % show bookmarks bar?
unicode=true, % non-Latin characters in Acrobat’s bookmarks
bookmarksnumbered=true,
bookmarksopen=false,
breaklinks=true,
backref=true,
pdftoolbar=true, % show Acrobat’s toolbar?
pdfmenubar=true, % show Acrobat’s menu?
pdffitwindow=false, % window fit to page when opened
pdfstartview={FitH}, % fits the width of the page to the window
pdftitle={Libro de Resumenes}
pdfauthor={Comités Organizador y Científico}
pdfsubject={R}, % subject of the document
pdfcreator={AucTeX/Emacs}, % creator of the document
pdfproducer={LaTeX}, % producer of the document
pdfnewwindow=true, % links in new window
pdfborder={0 0 0},
colorlinks=true, % false: boxed links; true: colored links
linkcolor=Brown, % color of internal links
citecolor=BrickRed, % color of links to bibliography
filecolor=black, % color of file links
urlcolor=Blue % color of external links
}
\usepackage[sectionbib]{chapterbib}
\usepackage[plain, spanish, noabstract, sort, nonamereplace]{flexbib}
\bibpunct{[}{]}{,}{n}{}{;}
\setcounter{tocdepth}{0}
\begin{document}
\frontmatter
\begin{titlingpage}
\title{III Jornadas de Usuarios de R\\
17 y 18 de Noviembre de 2011\\
EOI - Madrid\\
Libro de Resúmenes
}
\author{Comités Organizador y Científico}
\date{10 de Noviembre de 2011}
\maketitle
\end{titlingpage}
%[...]
\cleardoublepage
\tableofcontents
\mainmatter
\part{Mesa 1}
\label{mesa1}
\include{lorem_ipsum_dolor_sit_amet__consectetuer_adipiscing_elit_}
%[...]
\part{Autores e Instituciones}
\pagestyle{index}
\renewcommand{\indexname}{Índice de autores}
\printindex
\renewcommand{\indexname}{Índice de Instituciones}
\printindex[inst]
\end{document}