他大家
可以使用 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編寫程式?)