5.2.2 ⁑Sections and Publication Lists
Sections in your CV are created using:
where ⟨title⟩ is the section title and ⟨vspace⟩ is the height of the vertical space that can optionally be inserted after the title.
The text within the section is specified using:
where ⟨left⟩ is the text to place on the left of the vertical rule and ⟨right⟩ is the text to place on the right of the vertical rule. The optional argument is again the height of the vertical space that can be inserted after the text.
This example adds to the code from Example 26 so that it includes a section listing professional positions.
\documentclass[helvetica,narrow,a4paper]{europecv} \usepackage[T1]{fontenc} \usepackage{graphicx} % Specify personal data: \ecvname{Polly Parrot} \ecvaddress{42 The Lane, Some Town, Noshire AB1 2XY,
United Kingdom} \ecvtelephone[0712345678]{0123456789} \ecvemail{polly.parrot@example.com} \ecvnationality{British} \ecvdateofbirth{1970-12-31} \ecvgender{female} \ecvpicture[width=2in]{me}% me.pdf image file \begin{document} \begin{europecv} % display personal data: \ecvpersonalinfo \ecvsection{Professional Positions} \ecvitem{1990--8}{Junior assistant at ``Wibblies Avian Emporium''.} \ecvitem{1998--Present}{Senior assistant at ``The International Society of Duck and Geese
Co-operation''.} \end{europecv} \end{document}
(You can download or view this document.) The resulting document is shown in Figure 5.2.
Bibliographies are more problematic as the contents of the
europecv
environment are set using a longtable
environment
(which is why you have to use \ecvsection
rather than
\section
). This means that you can't just use \bibliography
within the right argument of \ecvitem
if the bibliography is
likely to span a page break. You can, however, simply place the bibliography
outside the europecv
environment, as shown below:
\begin{document} \begin{europecv} % display personal data: \ecvpersonalinfo % start a new section: \ecvsection{Professional Positions} \ecvitem{1990--8}{Junior assistant at ``Wibblies Avian Emporium''.} \ecvitem{1998--Present}{Senior assistant at ``The International Society of Duck and Geese Co-operation''.} \end{europecv} \bibliographystyle{plain} \nocite{*} \bibliography{mypublications} \end{document}
An alternative is to use the bibentry package2 (part of the natbib bundle [19]), which provides:
which is analogous to \bibliography
except that it doesn't
display the bibliography, and:
which displays the citation information for the reference identified by ⟨key⟩.
Example:
\documentclass[helvetica,narrow,a4paper]{europecv} \usepackage[T1]{fontenc} \usepackage{graphicx} \usepackage{bibentry} % add personal data here \begin{document} \bibliographystyle{plain} \nocite{*} \nobibliography{mypublications} \begin{europecv} % display personal data: \ecvpersonalinfo % start a new section: \ecvsection{Professional Positions} \ecvitem{1990--8}{Junior assistant at ``Wibblies Avian Emporium''.} \ecvitem{1998--Present}{Senior assistant at ``The International Society of Duck and Geese Co-operation''.} % publications section: \ecvsection{Publications} \ecvitem{}{\bibentry{mypub1}} \ecvitem{}{\bibentry{mypub2}} \end{europecv} \end{document}
This assumes a file called mypublications.bib contains the bibliography database, including the citations with the labels mypub1 and mypub2. Remember this requires a BibTeX run between LaTeX runs (see Volume 2).
Another possibility is to use the databib package (part of the datatool bundle). This has its own .bst BibTeX style that converts the bibliography data into one of datatool's internal databases. This is done using:
where ⟨bbl⟩ is the name of the .bbl file (defaults to
\jobname
.bbl), ⟨db-name⟩ is the name of the new
database and ⟨bib list⟩ is the list of .bib files
(without the .bib extension) where the bibliography data is
stored.
As with \bibliography
(see §5.1 The currvita Package
and Volume 2) you need to specify which citations you want
included in the .bbl file either via:
which also displays a reference in the text, or
which doesn't produce any text, but ensures that BibTeX includes the references in the .bbl file.
Example:
This will create a datatool internal database called
mypubdata that contains all the bibliographic data stored in
the file myrefs.bib. (As with \bibliography
, this
requires a BibTeX run between LaTeX runs to ensure the
citations are up-to-date.)
This database can be iterated over using \DTLforeach
(as described
in §2.7.1 Iterating Through a Database). However, since many of the fields
will be null depending on the entry type, it's easier to iterate
over the entries using:
This only makes local assignments, so it's no use in
a tabular
-like environment due to the scoping effect of
& and \\. Instead you can use:
which makes global assignments.
As with \DTLforeach
, there is also a starred version that performs
a read-only iteration of the database. The optional argument is
a conditional in the same format as the optional argument of
\DTLforeach
. There's no assignment list. Instead, you can
access the citation key (as used by \cite
and \bibitem
)
within ⟨body⟩ using:
The entry type (for example, book) is stored in:
(This will always be in lower case, regardless of the case used in the .bib file.) The remaining fields can be displayed using:
or they can be assigned to a control sequence ⟨cs⟩ using:
In both cases, ⟨field name⟩ is the column label, but no check is performed to determine if the column exists, so the result may be a null value (see §2.9 Null and Boolean Values). Available field labels are: Address, Author, BookTitle, Chapter, Edition, Editor, HowPublished, Institution, Journal, Key, Month, Note, Number, Organization, Pages, Publisher, School, Series, Title, Type, Volume, Year, ISBN, DOI, PubMed, Abstract and Url. These labels are case-sensitive (independent of the case used in the .bib file).
You can determine if a field exists within the ⟨body⟩ part of
\DTLforeachbibentry
or \gDTLforeachbibentry
using:
Since it's quite complicated working out which fields are relevant for which entry types, databib provides a convenient command that will format the entry in the current iteration according to its entry type:
By default, this only displays the fields that would typically be
displayed using the standard plain bibliography style, so
fields such as Url won't be displayed, even if they exist.
This command also doesn't use \bibitem
(recall Volume 1).
Since \bibitem
internally uses \item
, it's only
appropriate in a list context, but it's possible it may be needed
outside a list. Therefore databib provides:
This is similar to \bibitem
[
⟨label⟩]{
⟨key⟩}
, except that
it replaces \item
[
⟨label⟩]
with ⟨marker code⟩ and
sets the cross-reference text (that is, the reference text or number generated by
\cite
{key}
) to ⟨ref text⟩. Unlike the other commands described
above, \DTLcustombibitem
may be used outside the ⟨body⟩ argument
of both \DTLforeachbibentry
and \gDTLforeachbibentry
.
If you want to format a bibliographic entry outside of
\DTLforeachbibentry
/\gDTLforeachbibentry
you
can use:
where ⟨db-name⟩ is the label identifying the database and ⟨cite key⟩ is the label identifying the reference.
Using the above commands, it's possible to display a bibliography
within a longtable
. Recall from
Exercise 15 that TeX distributions come with an
example file called xampl.bib. This has
enough entries to test how well the code deals with page breaking,
and so will be used in this example.
The references in this example will be numbered (rather than using an author and year system), so a counter is defined to keep track of the numbering. (See Volume 1.)
\documentclass{article} \usepackage{longtable} \usepackage{databib} \newcounter{refcount} \newcommand*{\refmark}{\refstepcounter{refcount}[\therefcount]} \begin{document} \nocite{*} \DTLloadbbl{refdata}{xampl} \section*{Publications} \begin{longtable}{rp{0.5\textwidth}} \gDTLforeachbibentry{refdata} {% \DTLcustombibitem{\refmark}{\therefcount}{\DBIBcitekey} & \DTLformatbibentry\\ }% \end{longtable} \end{document}
This creates a four-paged document. The first page is shown in Figure 5.3. You can download or view this example document.
The data is unsorted, but remember that you can sort it using \DTLsort
(see §2.4 Sorting Data). For example, to sort in reverse
chronological order:
(The months should be specified using the BibTeX strings
JAN, FEB etc, instead of explicitly writing the
month names in order to sort the months in numerical order. You can
redefine \DTLmonthname
{
⟨number⟩}
to make the month names
appear in a different language.)
However, the database will be empty on the first run, which means you'll get an error if you try to sort it. You can test if the database is empty using:
where ⟨db-name⟩ is the label identifying the database. For example:
It's therefore possible to display your list of publications in
the europecv
environment, but it will be slow (since TeX
is doing the sorting and it requires iterating over a database).
This example again uses the sample xampl.bib file that comes with TeX distributions. You can replace xampl with the base name of your own personal .bib file.
\documentclass[helvetica,narrow,a4paper]{europecv} \usepackage[T1]{fontenc} \usepackage{graphicx} \usepackage{databib} % add personal data here % citation marker code: \newcounter{refcount} \newcommand*{\refmark}{\refstepcounter{refcount}[\therefcount]} \begin{document} \nocite{*} \DTLloadbbl{mypubdata}{xampl} \DTLifdbempty{refdata} {} {% \DTLsort*{Year=descending,Month=descending}{mypubdata} } \begin{europecv} % display personal data: \ecvpersonalinfo % start a new section \ecvsection{Professional Positions} \ecvitem{1990--8}{Junior assistant at ``Wibblies Avian Emporium''.} \ecvitem{1998--Present}{Senior assistant at ``The International Society of Duck and Geese Co-operation''.} % publications section \ecvsection{Publications} % iterate over bib data: \gDTLforeachbibentry*{mypubdata}% {% \ecvitem {% left column \DTLcustombibitem{\refmark}{\therefcount}{\DBIBcitekey}% }% {\DTLformatbibentry}% right column }% \end{europecv} \end{document}
(You can download or view this document.)
You may not want to include all the citations defined in your .bib
file. For example, you may only want to include your ten most recent
publications or you may only want to include just your books or journal
articles. This looks as though the solution can simply be obtained by
filtering the rows of data, but unfortunately there's a problem: the optional
argument of \gDTLforeachbibentry
doesn't work within the
longtable
environment. Nor does \ifthenelse
work within the
final argument of \gDTLforeachbibentry
when used inside
longtable
(although some of the etoolbox comparison commands,
such as \ifnumless
can).
When \gDTLforeachbibentry
fails in a tabular
-like
environment, we can go back to the technique used in the
solution to Exercise 11 and again employed in the
more adventurous section of Exercise 12, where the
commands described in §2.1.2 Hook Management were used to first
build a command that could subsequently be used in the problematic
environment.
Bearing in mind the above note, modify Example 29 so
that it just lists the ten most recent publications. You can keep track of the
current row within \DTLforeachbibentry
with the DTLbibrow
counter. As with \DTLforeach
, you can prematurely terminate the loop
at the end of the current iteration by placing \dtlbreak
anywhere
within ⟨body⟩.
Hint: you will need to use the standalone \DTLformatthisbibentry
command
instead of \DTLformatbibentry
and you can check if one integer value
is less than another integer value using etoolbox's
If you want to compare the value of a counter, you need to use
in ⟨number 1⟩ or ⟨number 2⟩.
You can download or view the solution to this part of the exercise.
For the More Adventurous
Instead of just the ten most recent publications, split the publication list into the three most recent articles, the three most recent books, the two most recent conference proceedings and the two most recent booklets.
You can download or view the solution to this part of the exercise.
Footnotes
- ... package2
- The documentation for bibentry is inside the bibentry.sty file.
This book is also available as A4 PDF or 12.8cm x 9.6cm PDF or paperback (ISBN 978-1-909440-07-4).