![行为类似于 \section 的自定义引用命令](https://linux22.com/image/441240/%E8%A1%8C%E4%B8%BA%E7%B1%BB%E4%BC%BC%E4%BA%8E%20%5Csection%20%E7%9A%84%E8%87%AA%E5%AE%9A%E4%B9%89%E5%BC%95%E7%94%A8%E5%91%BD%E4%BB%A4.png)
我有一个自定义引用命令。我希望它能像\section
命令一样运行,而不必像\section{\customcite{}}
我以前那样书写。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage{titlesec}
\titleformat{\section}{\large\bfseries}{}{0em}{}
\titleformat{\subsection}{\large\bfseries}{}{0em}{}
\usepackage[backend=biber]{biblatex}
\begin{filecontents}{\jobname.bib}
@article{einstein,
author = {Albert Einstein},
title = {the true about tree},
journaltitle = {Annalen der Physik},
year = {1905},
volume = {322},
number = {10},
pages = {891--921}
}
\end{filecontents}
\addbibresource{\jobname.bib}
% Cite, \customcite
\DeclareCiteCommand{\customcite}
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\ifciteindex
{\indexnames{labelname}%
\indexfield{indextitle}}
{}%
\printtext[bibhyperref]{%
\printnames{labelname}%
\space
\printfield{year}%
\addcolon\space%\setunit{\labelnamepunct}%
\printfield[citetitle]{labeltitle}%
}%
}
{\multicitedelim}
{\usebibmacro{postnote}}
\begin{document}
\section{\customcite{einstein}}
\customcite{einstein}
\end{document}
编辑:固定部分大小
答案1
\section
您可以定义一个调用和的命令\customcite
:
\newcommand\seccite[1]{\section{\customcite{#1}}}
然后使用\seccite{einstein}