
Quero criar um novo tipo de título. O título deve ficar assim.
O nome do cabeçalho deve ser “Myheader”. No momento resolvi o problema da seguinte forma:
\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}]
Ainda quero poder usar o \subsubsection
cabeçalho, então a solução não é aceitável. Um exemplo mínimo do código é:
\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}
Alguma idéia de como resolver isso ??
Responder1
Você pode corrigir o comando emitido para iniciar os apêndices, de modo que \section
produza os resultados corretos após esse ponto, ou seja, apenas para os apêndices. Isto garantirá que seus apêndices sejam colocados no nível correto dentro da hierarquia secional (por exemplo, para o ToC ou para marcadores) e tornará seu código flexível ao máximo (por exemplo, se você mudar de ideia, basta remover o patch).
Por exemplo:
\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}
EDITAR
Nos comentários você perguntou como modificar isso para obter cabeçalhos vazios nas páginas com emissão \section
posterior . \appendix
Seu comentário me leva a supor que você está usando fancyhdr
. Sem conhecer o código que você está usando atualmente para cabeçalhos em outros lugares, é difícil especificar a melhor maneira de fazer isso, mas se você tiver algo razoavelmente padrão, isso deve funcionar.
\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}
Observe que esta é uma interpretação literal da sua descrição e pode ou não ser o que você deseja. Em particular:
\section
seguinte\appendix
esvazia o cabeçalho da página atual, mesmo que a página também inclua um\section
anterior a\appendix
;- as páginas seguintes
\appendix
incluem um cabeçalho padrão se não incluírem\section
.
Se você não quiser cabeçalhos, afinal \appendix
. Você poderia usar:
\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.}}
As outras possibilidades aqui são mais complexas, então só pensarei nelas se necessário. Nesse caso, trabalharei a partir do seu código atual para os cabeçalhos, porque provavelmente será mais fácil sair fancyhdr
desse ponto. titleps
complementa titlesec
e funcionaria bem aqui.
EDITAR EDITAR
Em resposta à sua pergunta sobre correção \tableofcontents
de maneira semelhante, você certamente pode fazer isso. No entanto, admito que fiquei um pouco perdido em termos de como exatamente tudo deveria ser e não consegui descobrir exatamente o propósito do código que você postou. (Mas quebras de página explícitas e numeração de páginas não devem estar na definição de um estilo de página.)
Eu fiz isso:
\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.}}
o que me dá isso
Mas eu suspeito, agora, que você está apenas usando a classe errada. Se você usasse book
ou report
muito mais disso estaria lá para você de qualquer maneira. Com book
, por exemplo, você obtém uma classe semelhante a \frontmatter
\mainmatter and
\backmatter which 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 choose
book book`.or a