Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In the Mimic BibTeX "apalike" with BibLaTeX - (biblatex-apa broken?) the answer supplied is working fine until one needs to add a page number or "see:" to the citation the whole thing gets broken...

is there an easy way to fix it? Any other workaround?

bellow sample code and result:

% !TEX TS-program = arara
% !TEX encoding = UTF-8 Unicode

% arara: xelatex: { shell: true }
% arara: biber
% arara: xelatex: { shell: true }

\documentclass{article}
\usepackage{xcolor}
\usepackage{hyperref}
\hypersetup{%
    colorlinks=true, 
    citecolor=blue} 
\usepackage{polyglossia}
\setmainlanguage[variant=british]{english}

\usepackage{csquotes}

\PassOptionsToPackage{%
        natbib=true,
        style=authoryear-comp,
        hyperref=true,
        backend=biber,
        maxbibnames=99,
        firstinits=true,
        uniquename=init,
        maxcitenames=2,
        parentracker=true,
        url=false,
        doi=false,
        isbn=false,
        eprint=false,
        backref=true,
            }   {biblatex}
\usepackage{biblatex}



\renewcommand*{\postnotedelim}{\addcolon\space} % Xtras

\DeclareFieldFormat{postnote}{#1} % Xtras
\DeclareFieldFormat{multipostnote}{#1} % Xtras



\DeclareNameAlias{sortname}{last-first} 

% remove "in:" from articles. Thanks to Herbert.
\renewbibmacro{in:}{%
  \ifentrytype{article}{}{%
  \printtext{\bibstring{in}\intitlepunct}}}

% mit "month" and "language" from Bibliography
%%% \AtEveryBibitem{%
%%%  \clearfield{month}{}%
%%%  \clearlist{language}{}%
%%%  }

% some natbib backwards compatibility 
\let\citealp\cite
\let\cite\textcite

% increase vertical space between bibliography items.
\setlength\bibitemsep{0.5ex}
\setlength\bibnamesep{1.2ex}

% Comma before and after journal volume. Thanks to lockstep.
\renewbibmacro*{volume+number+eid}{%
  \setunit*{\addcomma\space}% NEW
  \printfield{volume}%
  \printfield{number}%
  \printfield{eid}}
  \DeclareFieldFormat[article]{number}{(#1)}% number of a journal

% Citation Hyperlinks (not just years), thanks to Audrey.
\makeatletter
\renewbibmacro*{cite}{% Based on cite bib macro from authoryear-comp.cbx
  \iffieldundef{shorthand}
    {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
       {\printtext[bibhyperref]{% Include labelname in hyperlink
          \DeclareFieldAlias{bibhyperref}{default}% Prevent nested hyperlinks
          \usebibmacro{cite:label}%
          \setunit{\addspace}%
          \usebibmacro{cite:labelyear+extrayear}}%
          \usebibmacro{cite:reinit}}
       {\iffieldequals{namehash}{\cbx@lasthash}
          {\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
                       \(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
             {\setunit{\addcomma}%
              \usebibmacro{cite:extrayear}}
             {\setunit{\compcitedelim}%
              \usebibmacro{cite:labelyear+extrayear}%
              \savefield{labelyear}{\cbx@lastyear}}}
          {\printtext[bibhyperref]{% Include labelname in hyperlink
             \DeclareFieldAlias{bibhyperref}{default}% Prevent nested hyperlinks
             \printnames{labelname}%
             \setunit{\nameyeardelim}%
             \usebibmacro{cite:labelyear+extrayear}}%
             \savefield{namehash}{\cbx@lasthash}%
             \savefield{labelyear}{\cbx@lastyear}}}}
    {\usebibmacro{cite:shorthand}%
     \usebibmacro{cite:reinit}}%
  \setunit{\multicitedelim}}

\renewbibmacro*{textcite}{% Based on textcite bib macro from authoryear-comp.cbx
  \iffieldequals{namehash}{\cbx@lasthash}
    {\iffieldundef{shorthand}
       {\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
                    \(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
          {\setunit{\addcomma}%
           \usebibmacro{cite:extrayear}}
          {\setunit{\compcitedelim}%
           \usebibmacro{cite:labelyear+extrayear}%
           \savefield{labelyear}{\cbx@lastyear}}}
       {\setunit{\compcitedelim}%
        \usebibmacro{cite:shorthand}%
        \global\undef\cbx@lastyear}}
    {\ifnameundef{labelname}
       {\printtext[bibhyperref]{% Include labelname in hyperlink
          \DeclareFieldAlias{bibhyperref}{default}% Prevent nested hyperlinks
          \iffieldundef{shorthand}
            {\usebibmacro{cite:label}%
             \setunit{%
               \global\booltrue{cbx:parens}%
               \addspace\bibopenparen}%
             \ifnumequal{\value{citecount}}{1}
               {\usebibmacro{prenote}}
               {}%
             \usebibmacro{cite:labelyear+extrayear}}
            {\usebibmacro{cite:shorthand}}%
          \ifthenelse{\iffieldundef{postnote}\AND
                      \(\value{multicitetotal}=0\AND\value{citetotal}=1\)}
            {\bibcloseparen% Include closing parenthesis in hyperlink
             \global\boolfalse{cbx:parens}}
            {}}}
       {\printtext[bibhyperref]{% Include labelname in hyperlink
          \DeclareFieldAlias{bibhyperref}{default}% Prevent nested hyperlinks
          \printnames{labelname}%
          \setunit{%
            \global\booltrue{cbx:parens}%
            \addspace\bibopenparen}%
          \ifnumequal{\value{citecount}}{1}
            {\usebibmacro{prenote}}
            {}%
          \iffieldundef{shorthand}
            {\iffieldundef{labelyear}
               {\usebibmacro{cite:label}}
               {\usebibmacro{cite:labelyear+extrayear}}%
             \savefield{labelyear}{\cbx@lastyear}}
            {\usebibmacro{cite:shorthand}%
             \global\undef\cbx@lastyear}%
          \ifthenelse{\iffieldundef{postnote}\AND
                      \(\value{multicitetotal}=0\AND\value{citetotal}=1\)}
            {\bibcloseparen% Include closing parenthesis in hyperlink
             \global\boolfalse{cbx:parens}}
            {}}%
          \savefield{namehash}{\cbx@lasthash}}}%
  \setunit{%
    \ifbool{cbx:parens}
      {\bibcloseparen\global\boolfalse{cbx:parens}}
      {}%
    \multicitedelim}}

\makeatother

% Backrefs "cited" instead of "cit"
\DefineBibliographyStrings{english}{%
backrefpage={cited on p\adddot},
backrefpages={cited on pp\adddot}
}


\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
    @article{Attanasio2010,
    abstract = {This paper provides a critical survey of the large literature on the life cycle model of consumption, both from an empirical and a theoretical point of view. It discusses several approaches that have been taken in the literature to bring the model to the data, their empirical successes and failures. Finally, the paper reviews a number of changes to the standard life cycle model that could help solve the remaining empirical puzzles.},
    author = {Kaminsky, Graciela Laura and Schmukler, Sergio L.},
    journal = {NBER Working Paper},
    month = feb,
    shorttitle = {Consumption and saving},
    title = {{Consumption and saving: models of intertemporal allocation and their implications for public policy}},
    url = {http://papers.ssrn.com/sol3/papers.cfm?abstract\_id=1558816 http://www.nber.org/papers/w15756},
    volume = {756},
    number = {12},
    year = {2010}
    }
    @article{Galindo2002,
    author = {Galindo, Arturo and Schiantarelli, Fabio and Weiss, Andrew},
    journal = {American Economic Review},
    month = apr,
    shorttitle = {Does Financial Liberalization Improve the Allocati},
    title = {{Does Financial Liberalization Improve the Allocation of Investment?: Micro Evidence from Developing Countries}},
    url = {http://ideas.repec.org/p/idb/wpaper/4295.html},
    volume = {47},
    number = {2},
    year = {2002}
    }
\end{filecontents}
\addbibresource{\jobname.bib}




\begin{document}
Finally, as written by \cite{Attanasio2010}, my Bibliography is cool \citep{Galindo2002}. Furthermore (see, for example, \citealp{Attanasio2010}) there are some cool tweaks.


\cite[see:][pg.~3]{Attanasio2010} here ,,see:'' should go before first author and constitute part of the link, also ,,pg.~3)'' should be part of the link

\citep[see:][pg.~3]{Galindo2002} here ,,see:'' should go before opening bracket and \emph{not} constitute part of the link, also ,,pg.~3'' should be part of the link



\printbibliography

\end{document}

enter image description here

share|improve this question
    
I could live with "see:" being simulated by regular text but having opening parentheses blue and the closing one black (whenever YYYY: PAGE is used) look awful :( biblatex-apa also won't do the job :( tex.stackexchange.com/questions/48557/… –  VladSkywalker Feb 5 at 0:30
    
Please make your code compile. It is impossible to reproduce your issue right now. First, xcolor needs a driver spec. I added xetex. Second, bib.bib is not standard. Either make sure your examples use a standard bib file or use filecontents to include a minimal one in your document. (Or, failing either of those, post a minimal bib file separately in your question.) –  cfr Feb 5 at 1:17
    
Is babel an option? I assume it would be easier to avoid polyglossia than biblatex. –  cfr Feb 5 at 1:28
    
@cfr i have added .bib with \usepackage{filecontents} @cfr unfortunately polyglossia is a must (multilingual bibliography, etc.) :( –  VladSkywalker Feb 5 at 12:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.