我有代码:
\definecolor{amaranth}{rgb}{0.9, 0.17, 0.31}
\titleformat{\section}
[runin]
{\color{amaranth}\sffamily\filright}
{\thesection}
{0.5em}
{}
\section{One}
\label{sec:One}
Reference the section One \textbf{\ref{sec:One}}
下面产生:
我希望得到以下结果:
\ref
希望命令,输入颜色\section
答案1
定义一个宏\secref
来格式化输出以满足您的需要:
\documentclass{article}
\usepackage{titlesec,xcolor}
\definecolor{amaranth}{rgb}{0.9, 0.17, 0.31}
\titleformat{\section}
[runin]
{\color{amaranth}\sffamily\filright}
{\thesection}
{0.5em}
{}
\newcommand{\secref}[1]{\textcolor{amaranth}{\bfseries\sffamily\ref{#1}}}
\begin{document}
\section{One}
\label{sec:One}
Reference the section One \secref{sec:One}.
\end{document}