
아래 MWE에서는 장 제목(이 경우에는 숫자만 필요함)의 위치를 여백과 닿는 모서리에 배치했습니다. 장 항목이 전혀 없는 것처럼 텍스트가 해당 위치에서 시작되도록 주위에 생성된 간격을 완전히 제거하려면 어떻게 해야 합니까?
\documentclass[12pt, oneside]{book}
\usepackage[showframe, paperwidth=30pc, paperheight=30pc, margin=5pc]{geometry}
\usepackage{tikz}
\usepackage{titlesec}
\titleformat{\chapter}
[block]% shape
{\filcenter\bfseries\large}% format applied to label+text
{}% label
{0pt}% horizontal separation between label and title body
{\maketitleframe{\thechapter}}% before the title body
\titlespacing{\chapter}{0pt}{0pt}{0pt}
\newcommand{\maketitleframe}[2]{%
\begin{tikzpicture}[overlay,remember picture]
\node[draw, rectangle, minimum size=5pc, yshift=-2.5pc, xshift=2.5pc] at (current page.north west) {#1};
\end{tikzpicture}% before the title body
}
\begin{document}
\chapter{}
test
\end{document}
답변1
또한 \titlespacing
다음을 변경하십시오 \chapter
.
\documentclass[12pt, oneside]{book}
\usepackage[showframe, paperwidth=30pc, paperheight=30pc, margin=5pc]{geometry}
\usepackage{tikz}
\usepackage{titlesec}
\titleformat{\chapter}
[block]% shape
{}% format applied to label+text
{}% label
{0pt}% horizontal separation between label and title body
{\maketitleframe{\thechapter}}% before the title body
\titlespacing{\chapter}{0pt}{0pt}{-2\baselineskip}
\newcommand{\maketitleframe}[2]{%
\begin{tikzpicture}[overlay,remember picture]
\node[draw, rectangle, minimum size=5pc, yshift=-2.5pc, xshift=2.5pc] at (current page.north west) {#1};
\end{tikzpicture}% before the title body
}
\begin{document}
\chapter{}
test
\end{document}
그러나 숫자만 원하고 실행 헤드나 ToC 항목도 없는 경우 다음을 tikzpicture
사용하지 않고 간단히 배치할 수 있습니다 \chapter
.
\documentclass[12pt, oneside]{book}
\usepackage[showframe, paperwidth=30pc, paperheight=30pc, margin=5pc]{geometry}
\usepackage{tikz}
\newcommand*{\chapternum}{%
\clearpage
\refstepcounter{chapter}%
\begin{tikzpicture}[overlay,remember picture]
\node[draw, rectangle, minimum size=5pc, yshift=-2.5pc, xshift=2.5pc] at (current page.north west) {\thechapter};
\end{tikzpicture}%
\ignorespaces
}
\begin{document}
\chapternum
test
\end{document}
또는 ToC 항목 및 실행 헤드 사용:
\documentclass[12pt, oneside]{book}
\usepackage[showframe, paperwidth=30pc, paperheight=30pc, margin=5pc]{geometry}
\usepackage{tikz}
\newcommand{\chapternum}[1]{%
\clearpage
\refstepcounter{chapter}%
\chaptermark{#1}%
\addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#1}%
\begin{tikzpicture}[overlay,remember picture]
\node[draw, rectangle, minimum size=5pc, yshift=-2.5pc, xshift=2.5pc] at (current page.north west) {\thechapter};
\end{tikzpicture}%
\ignorespaces
}
\begin{document}
\tableofcontents
\chapternum{}
test
\chapternum{ToC Entry and Head}
test
\clearpage
test
\clearpage
test
\end{document}