KOMA-Script でセクションタイトルのスペースを削除する方法

KOMA-Script でセクションタイトルのスペースを削除する方法

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} 

どちらの例も結果は次のようになります。

1. ABC o

注意: 2 つのドットが生成されるため、\autodotin を\sectionformatハードコードされたもの.(仕様により誤って配置されている in\autodotまたは on ) と組み合わせないでください。\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} 

どちらの結果も次のようになります:

o הדג .1 O

これは RL を使用する場合に正しいようです。

関連情報