参考书目编号下方的中心星号

参考书目编号下方的中心星号

大纲:我想在biblatex参考书目中突出显示某些感兴趣的参考文献(使用biber后端、样式chem-rsc和文章内twocolumn),并在参考编号下方使用单个星号或双星号。我希望在条目下方显示的文本包含在annote,显示没有问题,但未包含在此处。我搜索了这个网站,找到了一种在条目周围添加星号的方法来自 moewe并根据我的要求对其进行了调整(在参考编号下方,并在它们之间留有垂直空间)。\vspace手动设置,使其与第二行文本稍微对齐,这样就完全没问题了(在本例中)\vspace{0.36cm}

问题:moewe 改进的解决方案工作得很好,但是当引用数达到两位数时,由于必须指定长度,星号无法按照我希望的方式对齐,这时我遇到了问题。我可以让编号 <10 或 >10 的条目对齐,但不能同时对齐。我仍在学习 Latex,并了解了 moewe 的答案中的命令的作用,但我不确定如何将星号相对于参考编号框居中,例如,(17)因为我认为这是在框或类似构造中创建的biblatex。如果可能的话,我怎样才能自动将星号相对于上面的参考编号框的宽度居中,包括考虑潜在的字体大小变化?

梅威瑟:

% arara: pdflatex: {options: [-halt-on-error]}
% arara: biber
% arara: pdflatex: {options: [-halt-on-error]}
% arara: clean: {extensions: [log, run.xml, blg, bib, bcf, bbl, aux]}

\documentclass[twocolumn]{article}
\usepackage[backend=biber,natbib=true,style=chem-rsc]{biblatex}
\addbibresource{biblatex-examples.bib}
\addbibresource{\jobname.bib}

\newcommand{\impmarkstar}{\strut\vadjust{\domarksingle}}
\newcommand{\domarksingle}{%
    \vbox to 0pt{
        \vspace{0.36cm}
            \smash{\llap{*\kern-1.46em}}
            \vss
    }}
    
\newcommand{\impmarkdoublestar}{\strut\vadjust{\domarkdouble}}
\newcommand{\domarkdouble}{%
    \vbox to 0pt{
        \vspace{0.36cm}
            \smash{\llap{**\kern-1.7em}}
            \vss
    }}

\renewbibmacro*{begentry}{\ifkeyword{star}{\impmarkstar}{}%
    \ifkeyword{doublestar}{\impmarkdoublestar}{}}

\begin{filecontents}{\jobname.bib}
@article{SingleDigitSingleStar,
    author  = {Tim},
    title       = {Tittle},
    journal = {Applied Latex and a really long title so that it spans two lines},
    year        = {2018},
    keywords    = {star},
}
@article{SingleDigitDoubleStar,
    author  = {Tom},
    title       = {Titled},
    journal = {Applied Latex and a really long title so that it spans two lines},
    year        = {2019},
    keywords    = {doublestar},
}
@article{DoubleDigitSingleStar,
    author  = {Zeck},
    title       = {Titling},
    journal = {Applied Latex and a really long title so that it spans two lines},
    year        = {2020},
    keywords    = {star},
}
@article{DoubleDigitDoubleStar,
    author  = {Zack},
    title       = {Title},
    journal = {Applied Latex and a really long title so that it spans two lines},
    year        = {2017},
    keywords    = {doublestar},
}
\end{filecontents}

\nocite{*}

\begin{document}

\cite{SingleDigitSingleStar,SingleDigitDoubleStar}
\printbibliography

\end{document}

在 MWE 中,星号比在主文件中更靠左,因为我删除了等columnsep\footnotesize感兴趣的参考是前两个和最后两个参考。

笔记:这些来自我的实际文件书目(不是 MWE 和\footnotesize),其中指定为长度(*\kern-1.46em}**\kern-1.7em分别我理解这不是最好的,这包含在 MWE 中)以及我希望它如何用于所有参考文献,尽管最好是自动的:

单星号

双星号

具有上述长度的单个数字参考编号示例:

在此处输入图片描述

此外,由于它有点相关,如果有人可以评论我是否可以只使用前 X 个 biblatex 条目,biblatex-examples.bib我将不胜感激,这样我的 MWE 就可以变得更加简约,我不得不为此使用示例 .bib 的全部内容。

答案1

如果要将标记置于标签下方的中心,则需要测量当前条目的标签宽度并使用该宽度。(否则,当前条目的标签宽度不可用,因此我们使用内部宏再次测量它。)

然后,我们就只需要在边缘处移动,直到到达我们想要去的地方。

\documentclass[twocolumn]{article}
\usepackage[backend=biber,natbib=true,style=chem-rsc]{biblatex}

\makeatletter
\newlength\thislabelnumberwidth
\newcommand{\measurethislabeldwith}{%
  \ifundef\abx@field@shorthand
    {\blx@bbl@labelnumberwidth@numeric{this}}
    {\blx@bbl@labelnumberwidth@shorthand{this}}}
\makeatother

\newcommand{\impmark}[1]{\strut\vadjust{\domark{#1}}}
\newcommand{\domark}[1]{%
  \measurethislabeldwith
  \vbox to 0pt{%
    \leavevmode
    \kern\dimexpr\labelnumberwidth-\thislabelnumberwidth\relax
    \makebox[\thislabelnumberwidth][c]{#1}}}

\renewbibmacro*{begentry}{%
  \ifkeyword{star}{\impmark{*}}{}%
  \ifkeyword{doublestar}{\impmark{**}}{}}

\begin{filecontents}{\jobname.bib}
@article{SingleDigitSingleStar,
  author   = {Tim},
  title    = {Tittle},
  journal  = {Applied Latex and a really long title so that it spans two lines},
  year     = {2018},
  keywords = {star},
}
@article{SingleDigitDoubleStar,
  author   = {Tom},
  title    = {Titled},
  journal  = {Applied Latex and a really long title so that it spans two lines},
  year     = {2019},
  keywords = {doublestar},
}
@article{DoubleDigitSingleStar,
  author   = {Zeck},
  title    = {Titling},
  journal  = {Applied Latex and a really long title so that it spans two lines},
  year     = {2020},
  keywords = {star},
}
@article{DoubleDigitDoubleStar,
  author   = {Zack},
  title    = {Title},
  journal  = {Applied Latex and a really long title so that it spans two lines},
  year     = {2017},
  keywords = {doublestar},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}

\nocite{*}

\begin{document}
\cite{SingleDigitSingleStar,SingleDigitDoubleStar}
\printbibliography
\end{document}

标签下方有标记

相关内容