使用 \titleformat 对齐章节号

使用 \titleformat 对齐章节号

如果这个问题已经出现在这里,很抱歉!

我想看看如何“推动”章节的红色数字与段落对齐。正如您在下面看到的,红色数字距离右边距比距离段落稍远。

我怎能这样做?

多谢!

\documentclass[paper=A4,twoside=true,fontsize=10pt]{scrreprt}
\usepackage[paper=a4paper,includemp,top=2.25cm,left=3.75cm,right=0.75cm,bottom=1.5cm,marginparwidth=1.75cm]{geometry}

\usepackage[dvipsnames]{xcolor}
\usepackage{titlesec}
\usepackage{charter}

\setkomafont{chapter}{\fontfamily{phv}\fontsize{25}{25}\selectfont}

\titleformat{\chapter}[display]
    {\usekomafont{chapter}}
    {\vspace{-5.5em}\raggedleft{
        {\color{green}
            \rule[0pt]{2pt}{5cm}}\quad
        {\color{red}
            \fontsize{60}{60}\selectfont\thechapter}
        }
   }
   {-1.1em}
   {\raggedright}
   %[\vspace{-.55ex}\titlerule]

\setcounter{chapter}{13}

\begin{document}

\chapter{Pairing Lattices}
The cryptographic importance of efficiently computable, bilinear and non-degenerate pairings that are hard to invert in various ways has been amply demonstrated. The currently only known instantiations of pairings suitable for cryptography are the Weil and Tate pairings on elliptic curves or on Jacobians of more general algebraic curves. In view of the applications, efficient algorithms for computing these pairings are of great importance.
\end{document}

答案1

两个缺失的行尾注释符号产生了虚假的空格。参见哪些地方需要添加 % 来删除不需要的空格?

\documentclass[paper=A4,twoside=true,fontsize=10pt]{scrreprt}
\usepackage[paper=a4paper,includemp,top=2.25cm,left=3.75cm,right=0.75cm,bottom=1.5cm,marginparwidth=1.75cm]{geometry}

\usepackage[dvipsnames]{xcolor}
\usepackage{titlesec}
\usepackage{charter}

\setkomafont{chapter}{\fontfamily{phv}\fontsize{25}{25}\selectfont}

\titleformat{\chapter}[display]
    {\usekomafont{chapter}}
    {\vspace{-5.5em}\raggedleft{
        {\color{green}
            \rule[0pt]{2pt}{5cm}}\quad
        {\color{red}
            \fontsize{60}{60}\selectfont\thechapter}% <-- Crucial comment sign
        }% <-- Crucial comment sign
   }
   {-1.1em}
   {\raggedright}
   %[\vspace{-.55ex}\titlerule]

\setcounter{chapter}{13}

\begin{document}

\chapter{Pairing Lattices}
The cryptographic importance of efficiently computable, bilinear and non-degenerate pairings that are hard to invert in various ways has been amply demonstrated. The currently only known instantiations of pairings suitable for cryptography are the Weil and Tate pairings on elliptic curves or on Jacobians of more general algebraic curves. In view of the applications, efficient algorithms for computing these pairings are of great importance.
\end{document}

相关内容