我如何将以下内容从回忆录类“翻译”到报告类?我目前正在撰写报告类的论文,如果我可以使用这个章节标题就太好了:
\documentclass{memoir}
\usepackage{tikz, blindtext}
\makechapterstyle{box}{
\renewcommand*{\printchaptername}{}
\renewcommand*{\chapnumfont}{\normalfont\sffamily\huge\bfseries}
\renewcommand*{\printchapternum}{
\flushright
\begin{tikzpicture}
\draw[fill,color=black] (0,0) rectangle (2cm,2cm);
\draw[color=white] (1cm,1cm) node { \chapnumfont\thechapter };
\end{tikzpicture}
}
\renewcommand*{\chaptitlefont}{\normalfont\sffamily\Huge\bfseries}
\renewcommand*{\printchaptertitle}[1]{\flushright\chaptitlefont##1}
}
\chapterstyle{box}
\begin{document}
\chapter{Introduction}
\end{document}
答案1
以下是相当适当的改编memoir
的box
章节样式(左边是memoir
;右边是report
):
\documentclass{report}
\usepackage{tikz, lipsum}% http://ctan.org/pkg/{pgf,lipsum}
\newcommand*{\chapnumfont}{\normalfont\sffamily\huge\bfseries}
\newcommand*{\printchapternum}{
\begin{tikzpicture}
\draw[fill,color=black] (0,0) rectangle (2cm,2cm);
\draw[color=white] (1cm,1cm) node { \chapnumfont\thechapter };
\end{tikzpicture}
}
\newcommand*{\chaptitlefont}{\normalfont\sffamily\Huge\bfseries}
\newcommand*{\printchaptertitle}[1]{\flushright\chaptitlefont#1}
\makeatletter
% \@makechapterhead prints regular chapter heading.
% Taken directly from report.cls and modified.
\def\@makechapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \raggedleft
\ifnum \c@secnumdepth >\m@ne
\printchapternum
\par\nobreak
\vskip 20\p@
\fi
\interlinepenalty\@M
\printchaptertitle{#1}\par\nobreak
\vskip 40\p@
}}
% \@makeschapterhead prints starred chapter heading.
% Taken directly from report.cls and modified.
\def\@makeschapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \raggedleft
\interlinepenalty\@M
\printchaptertitle{#1}\par\nobreak
\vskip 40\p@
}}
\makeatother
\begin{document}
\chapter{Introduction}
\lipsum
\end{document}
我添加了一个类似的更新,用于\@makeschapterhead
设置带星号的章节标题。可能需要进行一些调整,但这留给读者自己决定。
答案2
必须采取的方法 »标题安全« (左边report
,右边memoir
)。
\documentclass[11pt]{report}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{titlesec}
\usepackage{tikz}
\usepackage{blindtext}
\newcommand*{\chapnumfont}{\normalfont\sffamily\huge\bfseries}
\titleformat{\chapter}[display]
{\filleft\bfseries\sffamily}
{\filleft%
\begin{tikzpicture}
\draw[fill,color=black] (0,0) rectangle (2cm,2cm);
\draw[color=white] (1cm,1cm) node {\chapnumfont\thechapter};
\end{tikzpicture}
}
{20pt}
{\Huge}
\begin{document}
\blinddocument
\end{document}