如果是 publist biblatex 选项(针对 .cls 文件)

如果是 publist biblatex 选项(针对 .cls 文件)

我有这种情况,我运行以决定一些选项publist。我尝试使用\ExecutePublistOptions{ }更改 publist 选项,但似乎这在 .cls 文件/序言中不起作用。我可以对于每个文档类选项,导入的biblatex方式不同,但由于大多数选项都是相同的,这似乎效率低下。

我想修改publist选项而不导入biblatex 每一个时间。这可能吗?(解决方案必须在序言/.cls 文件中起作用)

以下是 MWE:

\documentclass{article}

\usepackage{xcolor}
\definecolor{soft}{rgb}{0.45,0.45,0.45}
\newcommand{\softbullet}{\textcolor{soft}{\small\textbullet}\hspace{0.5em}}

\makeatletter
\newif\if@displayvon
%\DeclareOption{vonname=true}{\@displayvontrue}

\newif\if@publistnormal
%\DeclareOption{bib=normal}{\@publistnormaltrue}

\newif\if@publisthighlight
%\DeclareOption{bib=highlightname}{\@publisthighlighttrue}

\newif\if@publisthideonly
%\DeclareOption{bib=hidenameonly}{\@publisthideonlytrue}

\newcommand{\firstname}[1]{\def\@firstname{#1}}
\newcommand{\vonname}[1]{\def\@vonname{#1}}
\newcommand{\lastname}[1]{\def\@lastname{#1}}

\@publisthideonlytrue

\if@publistnormal
    \RequirePackage[%
            backend=biber,
            %bibstyle=publist,
            style=authoryear,
            hyperref=auto
        ]{biblatex}
    \AtEveryBibitem{\makebox[\bibhang][l]{\softbullet}}
\else
    \RequirePackage[%
            backend=biber,
            bibstyle=publist,
            labeldateparts=false,
            hyperref=auto
        ]{biblatex}
    \defbibenvironment{bibliography}
      {\list
         {\labelitemfont\softbullet}
         {\setlength{\leftmargin}{\bibhang}%
          \setlength{\itemsep}{\bibitemsep}%
          \setlength{\parsep}{\bibparsep}%
          \def\makelabel##1{\hss\llap{##1}}}}%
      {\endlist}
      {\item}
    \if@displayvon
        \plauthorname[\@firstname][\@vonname]{\@lastname}
    \else
        \plauthorname[\@firstname]{\@lastname}
    \fi
    \if@publisthideonly
        \ExecutePublistOptions{hlyear=false}
    \else\fi
    \if@publisthighlight
        \ExecutePublistOptions{plauthorhandling=highlight}
    \else\fi
\fi
\makeatother

\begin{filecontents}[overwrite]{sample.bib}
@book{dirac,
    title = {The Principles of Quantum Mechanics},
    author = {Paul Adrien Maurice Dirac},
    isbn = {9780198520115},
    series = {International series of monographs on physics},
    year = {1981},
    publisher = {Clarendon Press},
}
\end{filecontents}
\addbibresource{sample.bib}


\firstname{Paul Adrien Maurice}
\lastname{Dirac}

\begin{document}
Hello

\nocite{*}
\printbibliography

\end{document}

这是目前我能用 if 情况做的最好的事情(有效):

编辑:似乎\defbibenvironment ..在 publistnormal ifcase 末尾添加:\if@publistnormal ... \else ... \defbibenvironment \fi不起作用。因此,我得到的是:

\if@publistnormal
    \RequirePackage[%
            backend=biber,
            %bibstyle=publist,
            style=authoryear,
            hyperref=auto
        ]{biblatex}
    \AtEveryBibitem{\makebox[\bibhang][l]{\softbullet}}
\else
    \if@publisthideonly
        \RequirePackage[%
                hlyear=false, % 
                backend=biber,
                bibstyle=publist,
                labeldateparts=false,
                hyperref=auto
            ]{biblatex}
        \defbibenvironment{bibliography}
          {\list
             {\labelitemfont\softbullet}
             {\setlength{\leftmargin}{\bibhang}%
              \setlength{\itemsep}{\bibitemsep}%
              \setlength{\parsep}{\bibparsep}%
              \def\makelabel##1{\hss\llap{##1}}}}%
          {\endlist}
          {\item}
    \else
        \if@publisthighlight
            \RequirePackage[%
                    plauthorhandling=highlight, % 
                    backend=biber,
                    bibstyle=publist,
                    labeldateparts=false,
                    hyperref=auto
                ]{biblatex}
            \defbibenvironment{bibliography}
              {\list
                 {\labelitemfont\softbullet}
                 {\setlength{\leftmargin}{\bibhang}%
                  \setlength{\itemsep}{\bibitemsep}%
                  \setlength{\parsep}{\bibparsep}%
                  \def\makelabel##1{\hss\llap{##1}}}}%
              {\endlist}
              {\item}
        \else
            \RequirePackage[%
                    backend=biber,
                    bibstyle=publist,
                    labeldateparts=false,
                    hyperref=auto
                ]{biblatex}
            \defbibenvironment{bibliography}
              {\list
                 {\labelitemfont\softbullet}
                 {\setlength{\leftmargin}{\bibhang}%
                  \setlength{\itemsep}{\bibitemsep}%
                  \setlength{\parsep}{\bibparsep}%
                  \def\makelabel##1{\hss\llap{##1}}}}%
              {\endlist}
              {\item}
        \fi
    \if@displayvon
        \plauthorname[\@firstname][\@vonname]{\@lastname}
    \else
        \plauthorname[\@firstname]{\@lastname}
    \fi
    \fi
\fi

感觉好像应该有一些更简单的方法来做到这一点。也许可以通过某种方式将可选项直接传递给biblatexin \DeclareOption

也有可能没有更好的方法,在这种情况下我会接受它并使用我所拥有的。

澄清一下:所有\if@publisthighlight操作都是hlyear=false在导入 biblatex 时包括,并且\if@publisthideonly包括plauthorhandling=highlight

答案1

\ExecutePublistOptions在前言中确实有效,但只有在publist加载之后才有效(因为命令在那里定义)。

因此,像这样的事情(未经测试)实际上应该有效:

    \if@publistnormal
        \RequirePackage[%
                backend=biber,
                %bibstyle=publist,
                style=authoryear,
                hyperref=auto
            ]{biblatex}
        \AtEveryBibitem{\makebox[\bibhang][l]{\softbullet}}
    \else
       \RequirePackage[%
                    backend=biber,
                    style=publist,
                    labeldateparts=false,
                    hyperref=auto
                ]{biblatex}
    \fi
    \if@publisthideonly
        \ExecutePublistOptions{hlyear=false}
         \defbibenvironment{bibliography}
              {\list
                 {\labelitemfont\softbullet}
                 {\setlength{\leftmargin}{\bibhang}%
                  \setlength{\itemsep}{\bibitemsep}%
                  \setlength{\parsep}{\bibparsep}%
                  \def\makelabel##1{\hss\llap{##1}}}}%
              {\endlist}
              {\item}
      \else
          \if@publisthighlight
               \ExecutePublistOptions{plauthorhandling=highlight}
                \defbibenvironment{bibliography}
                  {\list
                     {\labelitemfont\softbullet}
                     {\setlength{\leftmargin}{\bibhang}%
                      \setlength{\itemsep}{\bibitemsep}%
                      \setlength{\parsep}{\bibparsep}%
                      \def\makelabel##1{\hss\llap{##1}}}}%
                  {\endlist}
                  {\item}
            \else
                \defbibenvironment{bibliography}
                  {\list
                     {\labelitemfont\softbullet}
                     {\setlength{\leftmargin}{\bibhang}%
                      \setlength{\itemsep}{\bibitemsep}%
                      \setlength{\parsep}{\bibparsep}%
                      \def\makelabel##1{\hss\llap{##1}}}}%
                  {\endlist}
                  {\item}
            \fi
        \if@displayvon
            \plauthorname[\@firstname][\@vonname]{\@lastname}
        \else
            \plauthorname[\@firstname]{\@lastname}
        \fi
        \fi
    \fi

相关内容