2

What I want: A different style for my own works in the Bibliography

What I did: Created bibliography entries, mywork and myworkimp: deleted on update: check below.

What I failed to do: Those entries will be printed in different styles (in bold or brown colour etc).


Update

After reading several other (than @samcarter's) comments in Tex.SE, I decided to switch to biblatex. Here's the new MWE:

\documentclass{book}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}

%%%%%% This was my pre-PhD work. I will only cite it, but not put in to contribution part.
%%%%%% This will be printed in Bibliography in Brown

@mywork{myfirst,
    author    = "Myself Me",
    title     = "Very good name",
    year      = "2016",
    publisher = "N/A",
    address   = "Earth"
}

%%%%%% This is my current work and will be in contribution part.
%%%%%% This will be printed in Bibliography in Bold font
@myworkimp{mysecond,
    author    = "Myself Me",
    title     = "No Name yet!",
    year      = "2018",
    publisher = "N/A",
    address   = "Earth",
}

\end{filecontents}

%%\usepackage[square, numbers, comma, sort&compress, ]{natbib} %sectionbib
\usepackage[firstinits=true,bibencoding=inputenc,hyperref=auto,refsection=chapter,backref=true,backend=biber, defernumbers=true,style=alphabetic,sorting=ynt]{biblatex}

\bibliography{\jobname} 
\usepackage[colorlinks]{hyperref}

\begin{document}

Dolor sit amet \autocite{myfirst}
Lor waht \autocite{mysecond}

\printbibliography[heading=bibnumbered]
\end{document}

Thanks for your help!

  • This could be easy to do if you would consider switching to biblatex. – user36296 May 30 '17 at 10:58
  • @samcarter There you go, mate. :-) – xxx--- May 30 '17 at 13:29
  • 1
    BTW: firstinits is a deprecated option, better use firstinits. But good choice to switch to biblatex! – user36296 May 30 '17 at 13:43
  • 2
    The options bibencoding=inputenc,hyperref=auto, should not be needed, they are more or less the default. defernumbers=true, is not needed with style=alphabetic, and sorting=ynt is unusual with style=alphabetic. – moewe May 30 '17 at 14:00
2

Thanks to moewe for his useful comments to improve this answer!

If you want to keep your syntax with @mywork a quick hack could be to declare special \DeclareBibliographyDriver for these types. Disadvantage: you loose the ability to differentiate between different types of documents for your own works, in the following example I simply choose book for both of them (please change to an appropriate type for your work). If you need the ability to differentiate between different types, you could for example add a special keyword for your own documents, see second solution below.

\documentclass{book}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}

%%%%%% This was my pre-PhD work. I will only cite it, but not put in to contribution part.
%%%%%% This will be printed in Bibliography in Brown

@mywork{myfirst,
    author    = "Myself Me",
    title     = "Very good name",
    year      = "2016",
    publisher = "N/A",
    address   = "Earth"
}

%%%%%% This is my current work and will be in contribution part.
%%%%%% This will be printed in Bibliography in Bold font
@myworkimp{mysecond,
    author    = "Myself Me",
    title     = "No Name yet!",
    year      = "2018",
    publisher = "N/A",
    address   = "Earth",
}

\end{filecontents}

%%\usepackage[square, numbers, comma, sort&compress, ]{natbib} %sectionbib
\usepackage[giveninits=true,bibencoding=inputenc,hyperref=auto,refsection=chapter,backref=true,backend=biber, defernumbers=true,style=alphabetic,sorting=ynt]{biblatex}


\usepackage[colorlinks]{hyperref}
\usepackage{xcolor}

\DeclareBibliographyAlias{mywork}{customa}
\DeclareBibliographyDriver{customa}{%
  \usedriver{\color{brown}}{book}%
}    

\DeclareBibliographyAlias{myworkimp}{customb}
\DeclareBibliographyDriver{customb}{%
  \usedriver{\bfseries}{book}%
}   

\bibliography{\jobname} 

\begin{document}

Dolor sit amet \autocite{myfirst}
Lor waht \autocite{mysecond}

\printbibliography[heading=bibnumbered]
\end{document}

enter image description here


Second solution using keywords

Advantage: you can have different types for your own works, for example mywork could be an article and a proceeding and myworkimp a book.

\documentclass{book}

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}

%%%%%% This was my pre-PhD work. I will only cite it, but not put in to contribution part.
%%%%%% This will be printed in Bibliography in Brown

@book{myfirst,
    author    = "Myself Me",
    title     = "Very good name",
    year      = "2016",
    publisher = "N/A",
    address   = "Earth",
    keywords   = "mywork"
}

%%%%%% This is my current work and will be in contribution part.
%%%%%% This will be printed in Bibliography in Bold font
@article{mysecond,
    author    = "Myself Me",
    title     = "No Name yet!",
    year      = "2018",
    publisher = "N/A",
    address   = "Earth",
    keywords   = "myworkimp"
}

\end{filecontents*}

%%\usepackage[square, numbers, comma, sort&compress, ]{natbib} %sectionbib
\usepackage[giveninits=true,bibencoding=inputenc,hyperref=auto,refsection=chapter,backref=true,backend=biber, defernumbers=true,style=alphabetic,sorting=ynt]{biblatex}

\usepackage[colorlinks]{hyperref}
\usepackage{xcolor}

\renewbibmacro*{begentry}{%
    \iffieldequalstr{keywords}{mywork}{\color{brown}}{}%
    \iffieldequalstr{keywords}{myworkimp}{\bfseries}{}%
}   

\bibliography{\jobname} 

\begin{document}

Dolor sit amet \autocite{myfirst}
Lor waht \autocite{mysecond}

\printbibliography[heading=bibnumbered]
\end{document}
  • Err...! I'm having one problem with my original source file. The bibliography is printed like [SMB17] bookS.... (book is printed at the beginning). Any idea why? – xxx--- May 30 '17 at 13:59
  • Also, backref is not working. – xxx--- May 30 '17 at 14:00
  • @pushpen.paul Can you show a MWE that demonstrates this problem? – user36296 May 30 '17 at 14:00
  • Mhhh. Doesn't \usedrivder have two arguments? \usedriver{initcode}{entrytype}. – moewe May 30 '17 at 14:02
  • 2
    @pushpen.paul The problem with "book" is solved in the edit. – user36296 May 30 '17 at 14:13

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.