他每个人
可以使用 KOMA 脚本的 \AddtoDoHook (如下面的 MWE 所示)来实现每个章节、章节、段落等的第一个字符的大写命令。
显然我想实现不同的命令
\AddtoDoHook{heading/endgroup/section}
\AddtoDoHook{heading/endgroup/paragraph}
我的MWE
\documentclass[a4paper]{scrbook}
% test_AddtoDoHook_02
\usepackage{ifthen}
\usepackage{tcolorbox}
\usepackage{polyglossia}
\setdefaultlanguage{french}
% 1 in order to capture section name:
\makeatletter
\newcommand{\titredesection}{\@currentheadentry}
\makeatother
% 2 condition to define titlebox bar ou foo (systematically):
\newcommand{\titretcb}{%
% Si la subsubsection est «foo», le titre est «bar»:
\ifthenelse{\equal{foo}{\titredesection}}%
{\tcbset{title=bar}}%
% sinon le titre des tcolorbox est «foo»:
{\tcbset{title=title is systematically foo except for foo !!!}}
}
%my test not OK
\makeatletter
\def\@firstCupcase@i#1#2,{\upcase{#1}#2}
\def\firstCupcase#1{\@firstCupcase@i#1,}
\makeatother
\begin{document}
% 3 use AddtoDoHook in one command for all document in order to control all box:
\AddtoDoHook{heading/endgroup/section}{\aftergroup\titretcb}
\AddtoDoHook{heading/endgroup/paragraph}{\aftergroup\firstCupcase}
\section{foo}
\paragraph{first paragraph}
this is start of...
\paragraph{second paragarph}
this is start of... ( here I would like >>This is start of... )
other start of line ( here I would like >>This is start of... )
other start of line ( here I would like >>Other is start of... )
\begin{tcolorbox}
There is foo citation
title colorbox should be bar.
\end{tcolorbox}
\section{bar}
\begin{tcolorbox}
There is bar citation
title colorbox should be foo.
\end{tcolorbox}
\section{egg}
\begin{tcolorbox}
There is egg citation
title colorbox should be foo.
\end{tcolorbox}
\end{document}
更一般地说,我希望命令在白线之后的每个起始行都以大写的第一个字符开始。
因此,对于我来说,检查每一行的第一个字符是否出现太困难了!!!
你能提出一个 MWE 吗?(我使用 lualatex,也许可以用 lua 编写程序?)