\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage{shortvrb}
\usepackage{ifthen}
\usepackage{color}
\usepackage{MnSymbol}
\MakeShortVerb{\|}

% Biblatex
\usepackage[style=apa,%
            bibencoding=inputenc]{biblatex}

\newcommand\apa[2][]{\ifthenelse{\equal{#1}{}}%
                       {\textcolor{blue}{\texttt{(APA #2)}}}%
                       {\textcolor{blue}{\texttt{(APA #2 Example #1)}}}}

\setlength{\parskip}{3ex}
\bibliography{biblatex-apa-test-citations,biblatex-apa-test-references}

\def\apaex#1{\hbox{\hspace{-4em}\texttt{\small \detokenize{#1}}}\\ $\rcurvearrowse$ \textbf{#1}}
\def\apaexs#1{\hbox{\texttt{\footnotesize \detokenize{#1}}} \textbf{\small #1}}

% This just makes it easier to find a specific (APA 7.x) example in the
% typeset references section
\reversemarginpar
\renewbibmacro*{begentry}{\marginpar{\footnotesize \textcolor{blue}{\thefield{entrykey}}}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%% END PREAMBLE %%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareLanguageMapping{american}{american-apa}

\begin{document}

\section*{|biblatex-apa| style examples}

This file typesets just about all useful examples from
\apa{6.11}--\apa{6.21} and \apa{7.01}--\apa{7.11}. Please refer to the
|biblatex-apa-test-references.bib| file for details on the references
entries. The |.bib| key for each entry in the References section is listed
for convenience in the left margin. The keys are not arbitrary and consist
of the APA section they are taken from (7.01--7.11), followed by a colon,
followed by the example number. This makes it easier to cross-reference
the typeset examples with the commented |.bib| file. I chose not to put the
examples in the References section in example number order so that the APA
requirements for References list alphabetisation and order could also be
demonstrated.

\section*{Citations}

\noindent Please see accompanying file |biblatex-apa-test-citations.bib|
for the bibliographic entries which these examples use.

\noindent\apa{6.11}\\
Simple cite. ``Jr.'' suffix is not shown (bib entry for this example has a suffix):\\
\apaex{\textcite{6.11}}

\noindent Within a paragraph, not in the ``narrative sense'':\\
\apaex{\parencite{6.11}}

\noindent To cite the parts separately:\\
\apaex{\citeyear{6.11}, \citeauthor{6.11}}

\noindent The per-paragraph rules for elision of years are more flexible in
APA 6th edition. There is more discretion to do this as the narrative
consistency suggests and so this style no longer automatically elides years
aver mention after the first within a paragraph. Cases can be handled as
per the examples above.

\noindent\apa{6.12} \apa{6.13}\\
Citations like\\
\apaex{\textcite{6.12a}}\\
which have two authors are never name-truncated after the first cite:\\
\apaex{\textcite{6.12a}}

\noindent First citation of 3--5 author entry:\\
\apaex{\textcite{6.12b}}

\noindent Subsequent first citations in a paragraph:\\
\apaex{\textcite{6.12b}}\\
Subsequent citations within a paragraph:\\
\apaex{\citeauthor{6.12b}}

\noindent Note that the dropping of the year for subsequent paragraph
citations is not automatic as there may be cases where you don't want to do
this (see APA 6.11).

\noindent\textcolor{red}{Note: The name list disambiguation required in the
  \emph{Exception:} clause here in the APA manual cannot be automated
  currently in |biblatex|. This is due to the underlying reliance on the
  |bibtex| |.bib| data model. This will change in a future |biblatex|
  release. See |biblatex-apa| docs.}

\noindent Multiple-authors in running text are separated by ``and''.
However, in parenthetical cites, multiple authors are separated by ``\&'':\\
\apaex{\textcite{6.12e}}\\
\apaex{\parencite{6.12f}}

\noindent The following citation should be name truncated on first cite
since it has six or more authors:\\
\apaex{\textcite{6.12g}}

\noindent\textcolor{red}{Note: The note above applies to the disambiguation
of entries with six or more names}

\noindent Now, following the examples in Table 6.1, p. 177 of the APA
manual. Note in the code that typesets these examples, |\citereset| is used
to pretend that the parenthetical examples are the first in the text.

\begin{center}
\begin{tabular}{lllll}
\textbf{\parbox{2cm}{\center Type of citation}} & \textbf{\parbox{2.4cm}{\center First
    citation in text}} & \textbf{\parbox{2.4cm}{\center Subsequent citations in
    text}} & \textbf{\parbox{2.4cm}{\center Parenthetical format, first citation
    in text}} & \textbf{\parbox{2.4cm}{\center Parenthetical format, subsequent
    citations in text}}\\\\
\hline
\\
\parbox{2cm}{One work by one author}
& \parbox{2.4cm}{\apaexs{\textcite{6.13a}}} &
\parbox{2.4cm}{\apaexs{\textcite{6.13a}}}\citereset
& \parbox{2.4cm}{\apaexs{\parencite{6.13a}}}
& \parbox{2.4cm}{\apaexs{\parencite{6.13a}}}\\\\
\parbox{2cm}{One work by two authors}
& \parbox{2.4cm}{\apaexs{\textcite{6.13b}}} & 
\parbox{2.4cm}{\apaexs{\textcite{6.13b}}}\citereset
& \parbox{2.4cm}{\apaexs{\parencite{6.13b}}}
& \parbox{2.4cm}{\apaexs{\parencite{6.13b}}}\\\\
\parbox{2cm}{One work by three authors}
& \parbox{2.4cm}{\apaexs{\textcite{6.13c}}} & 
\parbox{2.4cm}{\apaexs{\textcite{6.13c}}}\citereset
& \parbox{2.4cm}{\apaexs{\parencite{6.13c}}}
& \parbox{2.4cm}{\apaexs{\parencite{6.13c}}}\\\\
\parbox{2cm}{One work by four authors}
& \parbox{2.4cm}{\apaexs{\textcite{6.13d}}} & 
\parbox{2.4cm}{\apaexs{\textcite{6.13d}}}\citereset
& \parbox{2.4cm}{\apaexs{\parencite{6.13d}}}
& \parbox{2.4cm}{\apaexs{\parencite{6.13d}}}\\\\
\parbox{2cm}{One work by five authors}
& \parbox{2.4cm}{\apaexs{\textcite{6.13e}}} & 
\parbox{2.4cm}{\apaexs{\textcite{6.13e}}}\citereset
& \parbox{2.4cm}{\apaexs{\parencite{6.13e}}}
& \parbox{2.4cm}{\apaexs{\parencite{6.13e}}}\\\\
\parbox{2cm}{One work by six authors}
& \parbox{2.4cm}{\apaexs{\textcite{6.13f}}} & 
\parbox{2.4cm}{\apaexs{\textcite{6.13f}}}\citereset
& \parbox{2.4cm}{\apaexs{\parencite{6.13f}}}
& \parbox{2.4cm}{\apaexs{\parencite{6.13f}}}\\\\
\parbox{2cm}{Groups (readily identified through abbreviation) as authors}
& \parbox{2.4cm}{\apaexs{\textcite{6.13g}}} & 
\parbox{2.4cm}{\apaexs{\textcite{6.13g}}}\citereset
& \parbox{2.4cm}{\apaexs{\parencite{6.13g}}}
& \parbox{2.4cm}{\apaexs{\parencite{6.13g}}}\\\\
\parbox{2cm}{Groups (no abbreviation) as authors}
& \parbox{2.4cm}{\apaexs{\textcite{6.13h}}} & 
\parbox{2.4cm}{\apaexs{\textcite{6.13h}}}\citereset
& \parbox{2.4cm}{\apaexs{\parencite{6.13h}}}
& \parbox{2.4cm}{\apaexs{\parencite{6.13h}}}\\\\
\hline
\end{tabular}
\end{center}

\noindent\apa{6.14}\\
Citations of an entry with an author who shares a
surname with another entry always appears with initials:\\
\apaex{\textcite{6.14}}\\
and\\
\apaex{\textcite{7.01:3b}}\\\\
\textcolor{red}{Note: The second citation key here is taken from the APA
  references section as it is repeated there. This example is currently impossible to automate as
  it is, due to the nature of name list parsing in BibTeX. Disambiguation
  works between single names and not names within lists at the moment. The
  first example works due to a dummy single-name entry with the same
  surname in the |.bib| for the citation examples. See
 |biblatex-apa| docs. This is planned to be fully supported with |biblatex|
 2.x which should include the necessary underlying functionality}.

\noindent\apa{6.15}\\
Use |SHORTTITLE| field of the entry if it exists:\\
\apaex{\parencite{6.15a}}\\
Books, reports etc. use italics instead of quotes:\\
\apaex{\textcite{6.15b}}
Citing anonymous author:\\
\apaex{\textcite{6.15c}}

\noindent\apa{6.16}\\
Two or more works withing the same parentheses:\\
\apaex{\parencite{6.16a,6.16b}}\\
\apaex{\parencite{6.16c,6.16d,6.16e}}

\noindent Citations of works by same authors in the same  year:\\
\apaex{\parencite{6.16f,6.16g,6.16h,6.16i,6.16j}}\\\\
\textcolor{red}{Note: This example, (p. 178 APA Manual 6th edition, 2nd
  printing) is slightly odd as the ``in-press-a'' is not indicated and
  should be ``in-press'' since no other in press items are listed for the
  same authors in the example.}

\noindent Compact citations in alphabetic order:\\
\apaex{\parencite{6.16k,6.16l}}

\noindent Compact citations with special order:\\
\apaex{\parencites{6.16m}[see also][]{6.16n,6.16o}}

\noindent\apa{6.17}\\
Secondary sources:\\
\apaex{\parencite[as cited in][]{6.17}}\\

\noindent\apa{6.18}\\
Classical works:\\
\apaex{(\citeauthor{6.18a}, trans. \citeyear{6.18a})}\\
\textcolor{red}{Note: The example is managed using lower-level cite
  commands. This is another example of the APA not really thinking about
  automated processing and specifying an anomalous infix format. It would
  be better and probably acceptable for it to be:}\\
\apaex{\parencite[][trans.]{6.18a}}\\\\
Entries with an |ORIGYEAR| field will automatically use it:\\
\apaex{\textcite{6.18b}}\\\\
The other examples of standard classical texts in this section should just
be typed by hand--there is little benefit to automating these examples and
they wouldn't usually be in the References section anyway.

\noindent\apa{6.19}\\
These examples are easily dealt with using standard |biblatex| functionality.\\
\apaex{\parencite[][10]{6.19a}}\\
\apaex{\parencite[][Chapter 3]{6.19b}}\\

\noindent\apa{6.20}\\
Such cases are just typed out--they have no Reference section entry and
don't therefore have a bibliography database entry.

\noindent\apa{6.21}\\
Within parentheses, use the |\nptextcite| command which is equivalent to
the |\textcite| command but omits the parenthesis and uses commas instead.
See the |biblatex-apa| docs.\\
\apaex{(\nptextcite[see Table 3 of][]{6.21} for complete data)}

\noindent\apa{A7.07}\\
A patent citation uses the title but with no quotes\\
\apaex{\textcite{A7.07}}\\
\apaex{\parencite{A7.07}}

\newpage
\nocite{*}
% Exclude the citation examples from the References section - only want to
% see (APA 7.x) examples there.
\printbibliography[notkeyword=noinclude]
\end{document}















