특정 참고문헌 항목(예: "중요" 및 "수상" 논문)에 색상을 지정하고 싶습니다. 현재 내가 가지고 있는 것:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[backend=biber,
isbn=true,
giveninits=true,
style=numeric,
maxnames=99,
sorting=ydnt,
defernumbers=true,
autocite=superscript]{biblatex}
\defbibheading{bibliography}[\refname]{}
\addbibresource{references.bib}
\renewbibmacro{in:}{}
\usepackage[usenames,dvipsnames]{xcolor}
\DeclareBibliographyCategory{important}
\DeclareBibliographyCategory{award}
\addtocategory{important}{small}
\addtocategory{award}{big}
\AtEveryBibitem{
\ifcategory{award}%
{\color{blue}}%
{}%
\ifcategory{important}%
{\color{orange}}%
{}%
}
\begin{document}
\section{Main text}
\cite{small}
\cite{big}
\section{Bibliography}
\printbibliography
\end{document}
그러나 바이벤트리 자체만 주황색(또는 파란색, 아래 표시되지 않음)이며 옆에 있는 참조 번호는 없습니다. 어떻게 이를 달성할 수 있나요?
답변1
해당 카테고리의 참고문헌 항목 색상을 지정하기 위한 코드를 간단히 사용 \AtBeginBibliography
하고 설정할 수 있습니다 .\AtEveryBibitem
important
PS = 파일의 예시를 추가하지 않으 .bib
셨기 때문에 biblatex-examples.bib
.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[backend=biber,
isbn=true,
giveninits=true,
style=numeric,
maxnames=99,
sorting=ydnt,
defernumbers=true,
autocite=superscript]{biblatex}
\defbibheading{bibliography}[\refname]{}
\addbibresource{biblatex-examples.bib}
\renewbibmacro{in:}{}
\usepackage[usenames,dvipsnames]{xcolor}
\DeclareBibliographyCategory{important}
\addtocategory{important}{knuth:ct:a}
\addtocategory{important}{knuth:ct:c}
\AtBeginBibliography{%
\DeclareFieldFormat{labelnumberwidth}{\ifcategory{important}%
{\color{orange}\mkbibbrackets{#1}}%
{\mkbibbrackets{#1}}%
}}
\AtEveryBibitem{\ifcategory{important}
{\color{orange}}
{}}
\begin{document}
\section{Main text}
\cite{knuth:ct}
\cite{knuth:ct:a}
\cite{knuth:ct:b}
\cite{knuth:ct:c}
\cite{companion}
\section{Bibliography}
\printbibliography
\end{document}
편집하다:
명령 \ifcategory
에는 다음 구문이 있습니다.
\ifcategory{hcategoryi}{htruei}{hfalsei}
\if
다른 s 명령 과 유사합니다 biblatex
. 설명서 단락을 참조하세요. 4.6.2 "독립형 테스트".
원하는 만큼 s(또는 다른 s)를 중첩 할 수 htruei
있으며 , 모든 중괄호를 일치시키는 데만 주의하면 됩니다.hfalsei
\ifcategory
\if
다음은 세 가지 범주에 대해 세 가지 색상을 사용한 예입니다.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[backend=biber,
isbn=true,
giveninits=true,
style=numeric,
maxnames=99,
sorting=ydnt,
defernumbers=true,
autocite=superscript]{biblatex}
\defbibheading{bibliography}[\refname]{}
\addbibresource{biblatex-examples.bib}
\renewbibmacro{in:}{}
\usepackage[usenames,dvipsnames]{xcolor}
\DeclareBibliographyCategory{important}
\addtocategory{important}{knuth:ct:a}
\addtocategory{important}{knuth:ct:c}
\DeclareBibliographyCategory{awards}
\addtocategory{awards}{knuth:ct:b}
\DeclareBibliographyCategory{ducks}
\addtocategory{ducks}{companion}
\AtBeginBibliography{%
\DeclareFieldFormat{labelnumberwidth}%
{\ifcategory{important}% if
{\color{orange}\mkbibbrackets{#1}}% then
{\ifcategory{awards}% else if
{\color{blue}\mkbibbrackets{#1}}% then
{\ifcategory{ducks}% else if
{\color{green}\mkbibbrackets{#1}}% then
{{\mkbibbrackets{#1}}%else
}% end if
}% end if
}% end if
}}
\AtEveryBibitem%
{\ifcategory{important}% if
{\color{orange}}% then
{\ifcategory{awards}% else if
{\color{blue}}% then
{\ifcategory{ducks}% else if
{\color{green}}% then
{}%else
}% end if
}% end if
}% end if
\begin{document}
\section{Main text}
\cite{knuth:ct}
\cite{knuth:ct:a}
\cite{knuth:ct:b}
\cite{knuth:ct:c}
\cite{companion}
\section{Bibliography}
\printbibliography
\end{document}