行为类似于 \section 的自定义引用命令

行为类似于 \section 的自定义引用命令

我有一个自定义引用命令。我希望它能像\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}

相关内容