怎么在调用一条命令的时候输出该命令的名称

发布于 2021-11-19 10:49:21

比如说:

\documentclass[UTF8]{ctexart}
\title{你好,world!}
\author{Liam}
\date{\today}
\begin{document}
\maketitle
\section{你好中国}
中国在East Asia.
\subsection{Hello Beijing}
北京是capital of China.
\subsubsection{Hello Dongcheng District}
\paragraph{Tian'anmen Square}
is in the center of Beijing
\subparagraph{Chairman Mao}
is in the center of 天安门广场。
\subsection{Hello 山东}
\paragraph{山东大学} is one of the best university in 山东。
\end{document}

有没有可能在title的时候输出title,在section的时候输出section,在paragraph的时候输出paragraph呢?

查看更多

关注者
0
被浏览
945
3 个回答
雾月
雾月 2021-11-19
这家伙很懒,什么也没写!

没懂你想干什么。但是呢 LaTeX3 提供了一个 \cs_to_str:N 命令,用于输出控制序列的名字。

\documentclass{article}

\ExplSyntaxOn
\cs_new_protected_nopar:Npn \csusewithname #1
  {
    \cs_to_str:N #1
    #1
  }
\ExplSyntaxOff

\begin{document}

\csusewithname\section{sec 1}

\csusewithname\label{lab:1}
\ref{lab:1}

\end{document}

image.png

yangqingrong
yangqingrong 2021-11-23
这家伙很懒,什么也没写!

f

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览