2

I'm trying to get citations rendered like this: (Bunks et al. 2001; Alex 1999). Please mind there is no comma after author's name.

I already tried natbib, authordate1-4 packes but with no success. In many cases there is a comma between the author and the date.

  • With Natbib activated, and the plainnat style, try adding \setcitestyle{aysep={ }} to the preamble (Document --> Settings --> LaTeX preamble.) – Torbjørn T. Jun 10 '14 at 20:22
  • It works, great, thank you! But what about multiple references citation where each reference has a page. In Lyx I get this as a result: (Bunks et al. 2001; Alex 1999, page 22) But sometimes, I want have for each reference a page: (Bunks et al. 2001, page 50; Alex 1999, page 22) I've found some solutions, but I do not know how to apply them in Lyx: tex.stackexchange.com/questions/166097/… latex-community.org/forum/viewtopic.php?f=31&t=2840 – BenTreeser Jun 11 '14 at 17:12
  • If you're using the natbib package, you use the command (\citealt{bunks01,alex99}); here, bunks01 and alex99 would be the keys to the respective entries. – Mico Jun 11 '14 at 18:54
3

If you're using the natbib package (as would appear to be the case), you could use \citealt instead of the basic \citet macro; the former doesn't place parentheses around the year (in authoryear-style citations). To get a semicolon as the separator, issue the instruction \setcitestyle{aysep={; }} in Document --> Settings --> LaTeX preamble.

To generate two citation callouts each with their own notes (e.g., "page 50"), use two separate \citealt -- just like you would use two separate \citet commands if you wanted "ordinary" citation callouts that place parentheses around the publication's year.

In the LyX GUI, \citealt corresponds to the third citation style in the list one gets when right-clicking a citation:

enter image description here


LaTeX code and output

enter image description here

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{bunks01,
  author = "Bertram Bunks and Daffie Dunks and Fiona Funks",
  title  = "Random thoughts",
  journal= "Circular References",
  year   = 2001,
  volume = 1,
  number = 1,
  pages  = "1-11",
}
@misc{alex99,
  author = "Conrad Alex",
  title  = "Splits",
  year   = 1999,
}
\end{filecontents*}
\usepackage{natbib}
\setcitestyle{aysep={; }}
\bibliographystyle{plainnat}

\begin{document}
(\citealt{bunks01,alex99})

(\citealt[page~50]{bunks01}; \citealt[page~22]{alex99})
\bibliography{\jobname}
\end{document} 
1

natbib set to author-year style with the plainnat style is close, all you need is to change the separator between author and year. So, in Document --> Settings --> Bibliography select Natbib, and Author-year. In Document --> Settings --> LaTeX Preamble, add

\setcitestyle{aysep={ }}

which sets the author-year separator to a normal space. If you want a non-breakable space, so that a line break cannot occur between author and year, use \setcitestyle{aysep={~}}. Finally, set the bibliography style to plainnat in the settings for the BibTeX bibliography.


Regarding your second problem (which perhaps should have been posted as a second question), I don't know if there is a convenient way of doing that within LyX. You can type it manually, by adding the same citation twice with different citation styles, the first displaying only author, the second only year. You could also use egreg's solution to Natbib: Multiple citations with page numbers in one bracket but in that case you have to write the whole thing in an ERT I think, so you can't use LyX' GUI to find and insert the references.

If you want to do that, copy everything from \usepackage{xparse} to \ExplSyntaxOff into the preamble of your document and use the \multicitep macro in an ERT, inserted with Ctrl + L.

Example: The following code block is a .lyx file demonstrating this. Copy everything into an empty text file, save as something.lyx and open in LyX.

#LyX 2.0 created this file. For more info see http://www.lyx.org/
\lyxformat 413
\begin_document
\begin_header
\textclass article
\begin_preamble
\setcitestyle{aysep={ }}



\usepackage{xparse}
\ExplSyntaxOn

\makeatletter
\NewDocumentCommand{\multicitep}{m}
 {
  \NAT@open
  \mjb_multicitep:n { #1 }
  \NAT@close
 }
\makeatother

\seq_new:N \l_mjb_multicite_in_seq
\seq_new:N \l_mjb_multicite_out_seq
\seq_new:N \l_mjb_cite_seq

\cs_new_protected:Npn \mjb_multicitep:n #1
 {
  \seq_set_split:Nnn \l_mjb_multicite_in_seq { ; } { #1 }
  \seq_clear:N \l_mjb_multicite_out_seq
  \seq_map_inline:Nn \l_mjb_multicite_in_seq
   {
    \mjb_cite_process:n { ##1 }
   }
  \seq_use:Nn \l_mjb_multicite_out_seq { ;~ }
 }

\cs_new_protected:Npn \mjb_cite_process:n #1
 {
  \seq_set_split:Nnn \l_mjb_cite_seq { , } { #1 }
  \int_compare:nTF { \seq_count:N \l_mjb_cite_seq == 1 }
   {
    \seq_put_right:Nn \l_mjb_multicite_out_seq
     { \citeauthor{#1},~\citeyear{#1} }
   }
   {
    \seq_put_right:Nx \l_mjb_multicite_out_seq
     {
      \exp_not:N \citeauthor{\seq_item:Nn \l_mjb_cite_seq { 1 }},~
      \exp_not:N \citeyear{\seq_item:Nn \l_mjb_cite_seq { 1 }},~
      \seq_item:Nn \l_mjb_cite_seq { 2 }
     }
   }
 }
\ExplSyntaxOff
\end_preamble
\use_default_options true
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding auto
\fontencoding global
\font_roman default
\font_sans default
\font_typewriter default
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100

\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref false
\papersize default
\use_geometry false
\use_amsmath 1
\use_esint 1
\use_mhchem 1
\use_mathdots 1
\cite_engine natbib_authoryear
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\use_refstyle 1
\index Index
\shortcut idx
\color #008000
\end_index
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header

\begin_body

\begin_layout Standard
\begin_inset CommandInset citation
LatexCommand citep
key "Gostanza:TB21-3-235,Gourlay:TB8-2-128"

\end_inset


\end_layout

\begin_layout Standard
(
\begin_inset CommandInset citation
LatexCommand citeauthor
key "Gostanza:TB21-3-235"

\end_inset

, 
\begin_inset CommandInset citation
LatexCommand citeyear
key "Gostanza:TB21-3-235"

\end_inset

, p.
\begin_inset space ~
\end_inset

3; 
\begin_inset CommandInset citation
LatexCommand citeauthor
key "Granger:TB16-2-151"

\end_inset

, 
\begin_inset CommandInset citation
LatexCommand citeyear
key "Granger:TB16-2-151"

\end_inset

, p.
\begin_inset space ~
\end_inset

20)
\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
multicitep{Gostanza:TB21-3-235, p.~3; Granger:TB16-2-151, p.~20}
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset CommandInset bibtex
LatexCommand bibtex
bibfiles "tugboat"
options "plainnat"

\end_inset


\end_layout

\end_body
\end_document

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.