
這是 MWE:
\documentclass{scrartcl}
\usepackage{adforn}
\renewcommand{\sectionlinesformat}[4]{%
\ifstr{#1}{section}{%
{\adforn{30} {#3}. {#4} \adforn{58}}
}
{{\hskip#2#3}{#4}}%
}\makeatother
\begin{document}
\section{ABC}
\end{document}
我希望它會是:1.ABC並不是1. ABC (「1」和「.」之間沒有空格)。
有可能的?如果可能的話,我該怎麼做?
謝謝你!
答案1
該巨集末尾\sectionformat
包含一個。\enskip
沒有這個你可以重新定義它:
\documentclass{scrartcl}
\usepackage{adforn}
\def\sectionformat{\thesection\autodot}% \enskip
\renewcommand{\sectionlinesformat}[4]{%
\ifstr{#1}{section}{%
{\adforn{30} {#3}. {#4} \adforn{58}}
}
{{\hskip#2#3}{#4}}%
}\makeatother
\begin{document}
\section{ABC}
\end{document}
答案2
您應該將組大括號減少到最低限度,並將.
其中一個添加到\sectionformat
:
\documentclass{scrartcl}
\usepackage{adforn}
\renewcommand*{\sectionformat}{\thesection.\enskip}% replaced \autodot by .
\renewcommand{\sectionlinesformat}[4]{%
\ifstr{#1}{section}%
{\adforn{30} #3#4 \adforn{58}}%
{\hskip#2#3#4}%
}\makeatother
\begin{document}
\section{ABC}
\end{document}
或選擇numbers=withdot
將點新增至所有部分層級:
\documentclass[numbers=enddot]{scrartcl}
\usepackage{adforn}
\renewcommand{\sectionlinesformat}[4]{%
\ifstr{#1}{section}%
{\adforn{30} #3#4 \adforn{58}}%
{\hskip#2#3#4}%
}
\begin{document}
\section{ABC}
\end{document}
這兩個例子的結果是:
注意:您不應將\autodot
in\sectionformat
與硬編碼結合.
(無論是在規範中錯誤放置的位置\autodot
還是在\sectionlinesformat
其位置上),因為這可能會導致兩個點出現。
請查看KOMA-Script 手冊的預設值以及、和\sectionformat
的意義。numbers=withdot
\sectionformat
\autodot
順便說一句:\makeatother
您的範例中的 也不是必需的,應該刪除(所以我這樣做了)。
題外話:您也應該避免在程式碼中間透過換行符}
或真實空格來避免可能出現的虛假空格。{
正如評論聲稱這不適用於hebrew
:
\documentclass[numbers=enddot]{scrartcl}
\usepackage{polyglossia}
\setmainlanguage{hebrew}
\newfontfamily\hebrewfont[Script=Hebrew]{David CLM}
\newfontfamily\hebrewfonttt[Script=Hebrew]{Miriam Mono CLM}
\newfontfamily\hebrewfontsf[Script=Hebrew]{Simple CLM}
\usepackage{adforn}
\renewcommand{\sectionlinesformat}[4]{%
\ifstr{#1}{section}%
{\adforn{30} #3#4 \adforn{58}}%
{\hskip#2#3#4}%
}
\begin{document}
\section{גדה}
\end{document}
和
\documentclass{scrartcl}
\usepackage{polyglossia}
\setmainlanguage{hebrew}
\newfontfamily\hebrewfont[Script=Hebrew]{David CLM}
\newfontfamily\hebrewfonttt[Script=Hebrew]{Miriam Mono CLM}
\newfontfamily\hebrewfontsf[Script=Hebrew]{Simple CLM}
\usepackage{adforn}
\renewcommand*{\sectionformat}{\thesection.\enskip}% replaced \autodot by .
\renewcommand{\sectionlinesformat}[4]{%
\ifstr{#1}{section}%
{\adforn{30} #3#4 \adforn{58}}%
{\hskip#2#3#4}%
}
\begin{document}
\section{גדה}
\end{document}
兩者都會導致:
這對於使用 RL 來說似乎是正確的。