DALEIF1 边距顶部

DALEIF1 边距顶部

我是 texstackexchange 的新手...我使用 daleif1 主题作为我的标题:

 \documentclass{memoir}
    \usepackage{color,calc,graphicx,soul,fourier}
    \definecolor{nicered}{rgb}{.647,.129,.149}
    \makeatletter
    \newlength\dlf@normtxtw
    \setlength\dlf@normtxtw{\textwidth}
    \def\myhelvetfont{\def\sfdefault{mdput}}
    \newsavebox{\feline@chapter}
    \newcommand\feline@chapter@marker[1][4cm]{%
      \sbox\feline@chapter{%
        \resizebox{!}{#1}{\fboxsep=1pt%
          \colorbox{nicered}{\color{white}\bfseries\sffamily\thechapter}%
        }}%
      \rotatebox{90}{%
        \resizebox{%
          \heightof{\usebox{\feline@chapter}}+\depthof{\usebox{\feline@chapter}}}%
        {!}{\scshape\so\@chapapp}}\quad%
      \raisebox{\depthof{\usebox{\feline@chapter}}}{\usebox{\feline@chapter}}%
    }
    \newcommand\feline@chm[1][4cm]{%
      \sbox\feline@chapter{\feline@chapter@marker[#1]}%
      \makebox[0pt][l]{% aka \rlap
        \makebox[1cm][r]{\usebox\feline@chapter}%
      }}
    \makechapterstyle{daleif1}{
      \renewcommand\chapnamefont{\normalfont\Large\scshape\raggedleft\so}
      \renewcommand\chaptitlefont{\normalfont\huge\bfseries\scshape\color{nicered}}
      \renewcommand\chapternamenum{}
      \renewcommand\printchaptername{}
      \renewcommand\printchapternum{\null\hfill\feline@chm[2.5cm]\par}
      \renewcommand\afterchapternum{\par\vskip\midchapskip}
      \renewcommand\printchaptertitle[1]{\chaptitlefont\raggedleft ##1\par}
    }
    \makeatother
    \chapterstyle{daleif1}

在此处输入图片描述

我希望左上角有一个红色框。我已经尝试了几个小时,但没有任何结果……

有人能帮助我吗?

谢谢。

答案1

像这样?

在此处输入图片描述

唯一的变化是

 \renewcommand\printchapternum{\null\hfill\feline@chm[2.5cm]\par}

删除\null\hfill

代码:

\documentclass{memoir}
\usepackage{color,calc,graphicx,soul,fourier}
\usepackage{lipsum}

    \definecolor{nicered}{rgb}{.647,.129,.149}
    \makeatletter
    \newlength\dlf@normtxtw
    \setlength\dlf@normtxtw{\textwidth}
    \def\myhelvetfont{\def\sfdefault{mdput}}
    \newsavebox{\feline@chapter}
    \newcommand\feline@chapter@marker[1][4cm]{%
      \sbox\feline@chapter{%
        \resizebox{!}{#1}{\fboxsep=1pt%
          \colorbox{nicered}{\color{white}\bfseries\sffamily\thechapter}%
        }}%
      \rotatebox{90}{%
        \resizebox{%
          \heightof{\usebox{\feline@chapter}}+\depthof{\usebox{\feline@chapter}}}%
        {!}{\scshape\so\@chapapp}}\quad%
      \raisebox{\depthof{\usebox{\feline@chapter}}}{\usebox{\feline@chapter}}%
    }
    \newcommand\feline@chm[1][4cm]{%
      \sbox\feline@chapter{\feline@chapter@marker[#1]}%
      \makebox[0pt][l]{% aka \rlap
        \makebox[1cm][r]{\usebox\feline@chapter}%
      }}
    \makechapterstyle{daleif1}{
      \renewcommand\chapnamefont{\normalfont\Large\scshape\raggedleft\so}
      \renewcommand\chaptitlefont{\normalfont\huge\bfseries\scshape\color{nicered}}
      \renewcommand\chapternamenum{}
      \renewcommand\printchaptername{}
      \renewcommand\printchapternum{\feline@chm[2.5cm]\par}
      \renewcommand\afterchapternum{\par\vskip\midchapskip}
      \renewcommand\printchaptertitle[1]{\chaptitlefont\raggedleft ##1\par}
    }
    \makeatother
    \chapterstyle{daleif1}

\begin{document}

\chapter{Test chapter}
\lipsum[2]
\end{document}

在评论中,有人要求将标题向上移动,以便红框的上边框与页面上边框重合;这可以通过添加来实现

\setlength\beforechapskip{-135pt}

主题的定义,也许还有

\renewcommand*\printchapternonum{\phantom{\feline@chm[2.5cm]}\par}

因此未编号章节的标题不会太高。完整的示例:

 \documentclass{memoir}
\usepackage{color,calc,graphicx,soul,fourier}
\usepackage{lipsum}

    \definecolor{nicered}{rgb}{.647,.129,.149}
    \makeatletter
    \newlength\dlf@normtxtw
    \setlength\dlf@normtxtw{\textwidth}
    \def\myhelvetfont{\def\sfdefault{mdput}}
    \newsavebox{\feline@chapter}
    \newcommand\feline@chapter@marker[1][4cm]{%
      \sbox\feline@chapter{%
        \resizebox{!}{#1}{\fboxsep=1pt%
          \colorbox{nicered}{\color{white}\bfseries\sffamily\thechapter}%
        }}%
      \rotatebox{90}{%
        \resizebox{%
          \heightof{\usebox{\feline@chapter}}+\depthof{\usebox{\feline@chapter}}}%
        {!}{\scshape\so\@chapapp}}\quad%
      \raisebox{\depthof{\usebox{\feline@chapter}}}{\usebox{\feline@chapter}}%
    }
    \newcommand\feline@chm[1][4cm]{%
      \sbox\feline@chapter{\feline@chapter@marker[#1]}%
      \makebox[0pt][l]{% aka \rlap
        \makebox[1cm][r]{\usebox\feline@chapter}%
      }}
    \makechapterstyle{daleif1}{
      \renewcommand\chapnamefont{\normalfont\Large\scshape\raggedleft\so}
      \renewcommand\chaptitlefont{\normalfont\huge\bfseries\scshape\color{nicered}}
      \renewcommand\chapternamenum{}
      \renewcommand\printchaptername{}
      \setlength\beforechapskip{-135pt}
      \renewcommand\printchapternum{\feline@chm[2.5cm]\par}
      \renewcommand*\printchapternonum{\phantom{\feline@chm[2.5cm]}\par}%
      \renewcommand\afterchapternum{\par\vskip\midchapskip}
      \renewcommand\printchaptertitle[1]{\chaptitlefont\raggedleft ##1\par}
    }
    \makeatother
    \chapterstyle{daleif1}

\begin{document}

\chapter*{Test unnumbered chapter}
\lipsum[2]
\chapter{Test numbered chapter}
\lipsum[2]

\end{document}

在此处输入图片描述

相关内容