편집하다

편집하다

새로운 유형의 제목을 만들고 싶습니다. 제목은 다음과 같아야합니다.여기에 이미지 설명을 입력하세요

헤더 이름은 "Myheader"이어야 합니다. 지금은 다음과 같이 문제를 해결했습니다.

\makeatletter
\newcommand{\Myheader}{\subsubsection}
\makeatother
\titlespacing*{\subsubsection}{0cm}{0cm}{2pt}%pbk
\titleformat{\subsubsection}[display]{\Huge\filleft\scshape}{ \normalfont\bf\fontfamily{put}\fontseries{b}\fontsize{95pt}{0pt}\selectfont\thesection}{20pt}{}[\titlerule\vspace{2ex}\filright\vspace{2ex}]

여전히 헤더를 사용할 수 있기를 원하므로 \subsubsection솔루션이 허용되지 않습니다. 코드의 최소 예는 다음과 같습니다.

\documentclass[10pt,a4paper,oneside]{article}
\usepackage[danish,english]{babel}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\makeatletter
\newcommand{\Myheader}{\subsubsection}
\makeatother
\titlespacing*{\subsubsection}{0cm}{0cm}{2pt}%pbk
\titleformat{\subsubsection}[display]{\Huge\filleft\scshape}{ \normalfont\bf\fontfamily{put}\fontseries{b}\fontsize{95pt}{0pt}\selectfont\thesection}{20pt}{}[\titlerule\vspace{2ex}\filright\vspace{2ex}]
\begin{document}
\Myheader{The first appendix}
\end{document}

이 문제를 해결하는 방법을 아시나요?

답변1

부록을 시작하기 위해 실행된 명령을 패치하면 \section해당 지점 이후, 즉 부록에 대해서만 올바른 결과가 생성됩니다. 이렇게 하면 부록이 섹션 계층 내에서 올바른 수준에 배치되고(예: ToC 또는 책갈피용) 코드가 최대한 유연해집니다(예: 마음이 바뀌면 패치만 제거하면 됩니다).

예를 들어:

\documentclass[10pt,a4paper,oneside]{article}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{titlesec,etoolbox}
\usepackage{kantlipsum}
\apptocmd\appendix{%
  \titlespacing*{\section}{0cm}{0cm}{2pt}%pbk
  \titleformat{\section}[display]{\Huge\filleft\scshape}{ \normalfont\bfseries\fontfamily{put}\fontseries{b}\fontsize{95pt}{0pt}\selectfont\thesection}{20pt}{}[\titlerule\vspace{2ex}\filright\vspace{2ex}]
}{\typeout{Appendices title formatting successfully patched. Expect the expected.}}{\typeout{Appendices title formatting could not be patched. Unexpected results paradoxically to be expected.}}
\begin{document}
\section{A section}
\kant[1]
\section{Another section}
\kant[2]
\appendix
\section{The first appendix}
\kant[3]
\end{document}

패치된 부록

편집하다

의견에서 발행 \section후 페이지에 빈 헤더를 가져오기 위해 이를 수정하는 방법을 물었습니다. \appendix귀하의 의견에 따르면 귀하가 fancyhdr. 현재 다른 곳에서 헤더에 사용하고 있는 코드를 모르고 이를 수행하는 최선의 방법을 지정하기는 어렵지만 합리적인 표준이 있는 경우 이 방법이 작동할 것입니다.

\documentclass[10pt,a4paper,oneside]{article}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{titlesec,etoolbox,fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhf[lh]{\leftmark}
\fancyhf[rh]{\thepage}
\fancypagestyle{ancy}{%
  \fancyhf[h]{}%
  \renewcommand\headrulewidth{0pt}%
}
\usepackage{kantlipsum}
\apptocmd\appendix{%
  \titlespacing*{\section}{0cm}{0cm}{2pt}%pbk
  \titleformat{\section}[display]{\Huge\filleft\scshape}{ \normalfont\bfseries\fontfamily{put}\fontseries{b}\fontsize{95pt}{0pt}\selectfont\thesection}{20pt}{}[\titlerule\vspace{2ex}\filright\vspace{2ex}\thispagestyle{ancy}]
}{\typeout{Appendices title formatting successfully patched. Expect the expected.}}{\typeout{Appendices title formatting could not be patched. Unexpected results paradoxically to be expected.}}
\begin{document}
\section{A section}
\kant[1-4]
\section{Another section}
\kant[5]
\appendix
\section{The first appendix}
\kant[6-8]
\end{document}

부록의 새 섹션에 헤더가 없습니다.

이는 설명을 문자 그대로 해석한 것이며 원하는 것일 수도 있고 아닐 수도 있습니다. 특히:

  • \section다음은 \appendix페이지 \section에 이전 항목도 포함되어 있더라도 현재 페이지의 헤더를 비웁니다 \appendix.
  • 다음 페이지에 가 \appendix포함되지 않은 경우 표준 헤더가 포함됩니다 \section.

\appendix헤더를 전혀 원하지 않는 경우 . 다음을 사용할 수 있습니다.

\apptocmd\appendix{%
  \pagestyle{ancy}%
  \titlespacing*{\section}{0cm}{0cm}{2pt}%pbk
  \titleformat{\section}[display]{\Huge\filleft\scshape}{ \normalfont\bfseries\fontfamily{put}\fontseries{b}\fontsize{95pt}{0pt}\selectfont\thesection}{20pt}{}[\titlerule\vspace{2ex}\filright\vspace{2ex}\thispagestyle{ancy}]
}{\typeout{Appendices title formatting successfully patched. Expect the expected.}}{\typeout{Appendices title formatting could not be patched. Unexpected results paradoxically to be expected.}}

부록에 헤더가 전혀 없습니다

여기서 다른 가능성은 더 복잡하므로 필요한 경우에만 생각해 보겠습니다. 이 경우 헤더에 대한 현재 코드를 사용하여 작업하겠습니다. 왜냐하면 fancyhdr그 시점 에서 벗어나는 것이 가장 쉬울 것이기 때문입니다 . titleps보완 titlesec하고 여기서 잘 작동합니다.

편집 편집

\tableofcontents비슷한 방식으로 패치하는 것에 대한 질문에 대한 응답으로 확실히 이렇게 할 수 있습니다. 그러나 모든 것이 정확히 어떻게 생겼는지에 관해 약간의 이해가 부족했으며 게시한 코드의 목적을 정확하게 파악할 수 없었다는 점을 인정합니다. (그러나 명시적인 페이지 나누기 및 페이지 번호 매기기는 페이지 스타일 정의에 있어서는 안 됩니다.)

나는 이걸했다:

\pretocmd\tableofcontents{%
  \titlespacing*{\section}{0cm}{0cm}{2pt}%pbk
  \titleformat{\section}[display]{\Huge\filleft\scshape}{ \normalfont\bfseries\fontfamily{put}\fontseries{b}\fontsize{95pt}{0pt}\selectfont\thesection}{20pt}{}[\titlerule\vspace{2ex}\filright\vspace{2ex}\thispagestyle{ancy}]
}{\typeout{Contents title formatting successfully patched. Expect the expected.}}{\typeout{Contents title formatting could not be patched. Unexpected results paradoxically to be expected.}}
\apptocmd\tableofcontents{%
  \titlespacing*{\section}{0pt}{*5}{*2.5}%
  \titleformat{\section}[hang]{\normalfont\Large\bfseries}{\thesection}{1.5em}{}[\thispagestyle{fancy}]
}{\typeout{Contents title formatting successfully patched again. Expect the expected.}}{\typeout{Contents title formatting could not be patched again. Unexpected results paradoxically to be expected.}}

나에게 이것을주는

화려한 내용

하지만 지금은 당신이 정말로 잘못된 클래스를 사용하고 있다고 생각합니다. 당신이 book이것을 사용한다면 report어쨌든 당신을 위해 거기에 있을 것입니다. 예를 들어 를 사용하면 \mainmatter \backmatter book 책과 같은 클래스를 book얻을 수 있습니다 .\frontmatterandwhich are starting to look suspiciously like code you are trying to create here. If so, don't reinvent the wheel - use the right tool for the job and chooseor a

관련 정보