0

I would like to recover this question I asked some time back since I managed to find no solution of my own to it. Any suggestions or ideas are welcomed:

I am using the following bibliography style:

    \def\style{plainnat}    

I want the citation key to appear alongside the bibliography item. To have this printed, I have the following snippet:

\makeatletter
\def\@lbibitem[#1]#2{%
\if\relax\@extra@b@citeb\relax\else
\@ifundefined{br@#2\@extra@b@citeb}{}{%
\@namedef{br@#2}{\@nameuse{br@#2\@extra@b@citeb}}}\fi
\@ifundefined{b@#2\@extra@b@citeb}{\def\NAT@num{}}{\NAT@parse{#2}}%
\item[\hfil\hyper@natanchorstart{#2\@extra@b@citeb}\citep{#2}%
\hyper@natanchorend]%
\NAT@ifcmd#1(@)(@)\@nil{#2}}
\makeatother

I am compiling the bibliography using Biblatex using

\bibliography{imaging_and_metrology}\bibliographystyle{\style}

However, adding the citation keys makes the first line of each bibliography entry be left shifted as illustrated below:

Hanging citation

How can I correct the ident so it is aligned with the page margins? \setlength\bibhang{} does not work here. The complete MWE that contains the above is as follows:

\documentclass[a4paper,10pt,reqno,oldfontcommands]{memoir} 

\makeindex

\usepackage[T1]{fontenc}
\usepackage{amsthm}                         % Calls AMS theorem environment
\usepackage{mathrsfs}                           % Even more math symbols
\usepackage{newpxtext,newpxmath}
\usepackage{mathtools}                          % Needed to define adjustable abs and norms
\usepackage{layouts}                            % Layout diagrams
\usepackage{graphicx}                           % Calls figure environment
\usepackage{longtable,rotating}                     % Long tab environments including rotation. 
\usepackage[utf8]{inputenc}                     % Needed to encode non-english characters directly for mac  
\usepackage{url}                                % Supports url commands
\usepackage{subcaption}                         % Required to remove double parentheses for caption figures.
\usepackage[square,sort&compress]{natbib}           % For bibliography
\usepackage[english]{babel}                     %For languages characters and hyphenation

\def\style{plainnat}                                % Sets bibliography style

%%% This adds the citation key.
\makeatletter
\def\@lbibitem[#1]#2{%
\if\relax\@extra@b@citeb\relax\else
\@ifundefined{br@#2\@extra@b@citeb}{}{%
\@namedef{br@#2}{\@nameuse{br@#2\@extra@b@citeb}}}\fi
\@ifundefined{b@#2\@extra@b@citeb}{\def\NAT@num{}}{\NAT@parse{#2}}%
\item[\hfil\hyper@natanchorstart{#2\@extra@b@citeb}\citep{#2}%
\hyper@natanchorend]%
\NAT@ifcmd#1(@)(@)\@nil{#2}}
\makeatother

\usepackage[dvipsnames]{xcolor}
\definecolor{myblue}{named}{MidnightBlue}
\usepackage[colorlinks=true,citecolor=myblue,linkcolor=myblue,urlcolor=myblue]{hyperref}    

\begin{document}

\chapter{Some chapter}
This is an example chapter with some citation~\citep{Fano1957_RMP}. I am using the \emph{plainnat} style for the bibliography. Since I want to add the citation key with the bib item, the indentation of the first line is not aligned with the page margins


\bibliography{Biblio_thesis}\bibliographystyle{\style}

\end{document}

where the citation key has the following Bibtex item:

@article{Fano1957_RMP,
    Author = {Fano, U.},
    Date-Added = {2018-08-07 13:00:54 +0100},
    Date-Modified = {2018-08-07 13:02:07 +0100},
    Doi = {10.1103/RevModPhys.29.74},
    Journal = {Rev. Mod. Phys.},
    Month = {January},
    Number = {1},
    Pages = {74--93},
    Title = {Description of States in Quantum Mechanics by Density Matrix and Operator Techniques},
    Volume = {29},
    Year = {1957}}
2
  • 1
    The code you have shown so far strongly suggests you are not actually using biblatex (notice the la) you seem to use natbib. I have removed the biblatex tag. Unfortunately, it is quite hard to reproduce what you are seeing with just a few snippets of code. You could make it much easier for us to help you if you could provide a minimal, yet compilable example document that shows the error, an MWE: tex.meta.stackexchange.com/q/228/35864
    – moewe
    Commented Aug 18, 2018 at 12:41
  • @moewe, you are correct. I will add the natbib tag and add a MWE.
    – Sid
    Commented Aug 18, 2018 at 12:54

1 Answer 1

0

For anyone experiencing similar problems with the memoir class, I slightly adapted the code snippet given by gmedina in this post:

\makeatletter
\renewcommand\@biblabel[1]{#1} % No brackets for the references
\renewenvironment{thebibliography}[1]
  {\chapter{\refname}%
   \@mkboth{\MakeUppercase\refname}{\MakeUppercase\refname}%
   \list{\@biblabel{\@arabic\c@enumiv}}%
        {\settowidth\labelwidth{\@biblabel{#1}}%
         \leftmargin\labelwidth
         \advance\leftmargin20pt% change 20 pt according to your needs
         \advance\leftmargin\labelsep
         \setlength\itemindent{-20pt}% change using the inverse of the length used before
         \@openbib@code
         \usecounter{enumiv}%
         \let\p@enumiv\@empty
         \renewcommand\theenumiv{\@arabic\c@enumiv}}%
   \sloppy
   \clubpenalty4000
   \@clubpenalty \clubpenalty
   \widowpenalty4000%
   \sfcode`\.\@m}
  {\def\@noitemerr
    {\@latex@warning{Empty `thebibliography' environment}}%
   \endlist}
\renewcommand\newblock{\hskip .11em\@plus.33em\@minus.07em}
\makeatother

Add to preamble.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .