我想使用从朋友那里获得的代码重新定义章节标题。当我创建 dvi 并在 Okular 中看到它时,它工作正常(使用 Evince 看起来不太好),但当我尝试使用 pdflatex 或 dvipdf 生成 pdf 时,标题看起来不对。我不知道问题出在哪里。
这是一个例子。提前致谢。
\documentclass{report}
\usepackage{psboxit}
\usepackage{pstricks}
% Title for chapters
\makeatletter
\def\thickhrulefill{\leavevmode \leaders \hrule height 1ex \hfill \kern \z@}
\def\@makechapterhead#1{%
\reset@font
\parindent \z@
\vspace*{10\p@}%
\hbox{%
\vbox{%
\hsize=2cm%
\begin{tabular}{c}
\scshape \strut \@chapapp{} \\
\psboxit{box 0 0 0 setrgbcolor fill}{%
\vrule depth 8em width 0pt%
\vrule height 0pt depth 0pt width 10pt%
{\white \LARGE \bfseries
\strut \vrule height 1em depth 0pt width 0pt
\thechapter}%
\vrule height 0pt depth 0pt width 10pt%
}
\end{tabular}%
}%
\vbox{%
\advance\hsize by -2cm
\hrule height 0.4pt depth 0pt width \hsize
\par
\vskip 6pt%
\hspace{20pt}%
\parbox{260pt}{%
\LARGE \bfseries #1
}%
}%
}%
\vskip 100\p@
}
\begin{document}
\chapter{Introduction}
Intro here.
\end{document}
答案1
这是一个可能的解决方案标题安全和蒂克兹;章节标题的新样式通过命令定义:
\documentclass[twoside]{report}
\usepackage[rigidchapters,explicit]{titlesec}
\usepackage{tikz}
\usepackage{lipsum}
\newcommand\MyChapFormat{%
\titleformat{\chapter}[block]
{ }{}{0pt}
{\begin{tikzpicture}[%
blackrec/.style={draw,fill=black,minimum height=3cm,minimum width=0.8cm},%
remember picture,overlay]
\node[blackrec] (BS) at (0.5,0) {};
\node[anchor=north,yshift=-0.3cm] at (BS.north)%
{\textcolor{white}{\Large\bfseries\thechapter}};
\node[anchor=south] at (BS.north) {\scshape\chaptername};
\draw[ultra thick] (1.6,1) -- (\textwidth,1);
\node[anchor=north,align=left,text width=0.83\textwidth,xshift=6cm,yshift=-0.1cm] at (1,1)
{\bfseries\Large##1};
}
[\end{tikzpicture}]
\titlespacing{\chapter}{0pt}{0pt}{150pt}
}
\begin{document}
\tableofcontents
\MyChapFormat
\chapter{Introduction }
\lipsum[1]
\end{document}
结果如下(我只为“简介”对应的章节添加了一张图片):
答案2
答案3
你也可以尝试使用 dvips 和然后转换为 PDF;这将使 PSTricks 代码有机会运行……