Titlesec: 위쪽 여백에 있는 장

Titlesec: 위쪽 여백에 있는 장

페이지 상단에 오도록 장이나 섹션 제목을 여백에 넣으려면 어떻게 해야 합니까?

이것이 내가 원하는거야:

여기에 이미지 설명을 입력하세요

그러나 다음 MWE는

\documentclass{book}
\usepackage{lipsum,titletoc,marginnote}
\usepackage[explicit]{titlesec}

\usepackage{geometry}
% page layout
\geometry{%
    showframe,
    top=4cm,
    headsep=1.5cm,
    bottom=3cm,
    innermargin=3.0cm,
    textwidth=300pt,
    marginparwidth=4.0cm,
    marginparsep=1.5cm,
    heightrounded,
}%

\titleformat{\chapter}[rightmargin]{\Large}{Chapter~\thechapter}{10pt}{#1}


\begin{document}


\chapter{Background}

\lipsum[1]

% the following is needed or the chapter will not be displayed at all
\section{Related Work} 
\lipsum[99]

\end{document}

여기에 이미지 설명을 입력하세요

답변1

스타일에 따른 솔루션은 다음과 같습니다 display.

\documentclass{book}
\usepackage{lipsum,titletoc,marginnote, array}
\usepackage[explicit]{titlesec}
\usepackage[x11names]{xcolor}

\usepackage{geometry}
% page layout
\geometry{%
    showframe,
    top=4cm,
    headsep=1.5cm,
    bottom=3cm,
    innermargin=3.0cm,
    textwidth=300pt,
    marginparwidth=4.0cm,
    marginparsep=1.5cm,
    heightrounded,
}%

\titleformat{\chapter}[display]{\LARGE\filleft\sffamily\bfseries\color{SlateGray3}}{}{0pt}{\leavevmode%
\rlap{\hskip\marginparsep\smash{\begin{tabular}[t]{@{} >{\centering}p{\marginparwidth}@{}}Chapter~\thechapter\\#1\end{tabular}}}}[\vskip-2.63ex]%
\titlespacing{\chapter}{0pt}{-9ex}{0pt}

\begin{document}


\chapter{Background}

\lipsum[1]

% the following is needed or the chapter will not be displayed at all
\section{Related Work}
\lipsum[99-102]

\end{document}

여기에 이미지 설명을 입력하세요

답변2

배치를 사용할 수 있지만 클래스 의 구성원을 rightmargin만들어야 합니다 .\chapterstraight

\documentclass{book}
\usepackage{titlesec,marginnote}
\usepackage{etoolbox}
\usepackage{lipsum}

\usepackage{geometry}
% page layout
\geometry{%
    showframe,
    top=4cm,
    headsep=1.5cm,
    bottom=3cm,
    innermargin=3.0cm,
    textwidth=300pt,
    marginparwidth=4.0cm,
    marginparsep=1.5cm,
    heightrounded,
}%

\titleclass{\chapter}{straight}
\titleformat{\chapter}[rightmargin]
  {\Large}
  {\makebox[0pt][l]{Chapter~\thechapter}}
  {10pt}
  {\marginchapter}
\preto\chapter{\cleardoublepage}
\newcommand{\marginchapter}[1]{%
  \makebox[0pt][l]{%
    \parbox[t]{\marginparwidth}{%
      \raggedright#1%
    }%
  }%
}

\begin{document}

\chapter{Background}

\lipsum[1]

\section{Related Work} 
\lipsum[99]

\end{document}

여기에 이미지 설명을 입력하세요

관련 정보