编译“Thinking Forth” LaTeX 源代码

编译“Thinking Forth” LaTeX 源代码

我有一本好书“Thinking Forth”,其中有可用的 LaTeX 代码。(http://thinking-forth.sourceforge.net

源代码使用了 PSTricks,所以我试图删除依赖 PSTricks 的代码。最大的障碍是转换\tip环境,可以使用如下方法

\documentclass[12pt, english]{book}

    \def\tfoptions{6.14x9.21,2004,tip,tipno,leo,isbn,bnw}

    \usepackage{pst-all}
    \usepackage{pst-blur}
    \usepackage{pst-grad}
    \usepackage{babel}
    \usepackage{fancyvrb}
    \usepackage{graphicx}
    \usepackage{geometry}
    \usepackage[\tfoptions]{tf}
    \usepackage[colorlinks=true,linkcolor=\linkcolor,citecolor=\linkcolor,urlcolor=\linkcolor]{hyperref}

\begin{document}
    Hello.
    \begin{tip}
    Hello,     Hello.     Hello.    Hello.    Hello.    Hello.
    \end{tip}
\end{document}

获得此 pdf 结果。提示环境非常智能,它根据偶数/奇数页显示正确的左手指或右手指指向。

在此处输入图片描述

我需要使用三个命令将 PSTrick 代码制作成 pdf 文件。

latex --output=ps tip.tex
dvips tip.dvi
ps2pdf tip.ps

tf.sty文件中,tip 环境调用\tipbox

\newenvironment{tip}{
\list{}{\listparindent 0pt\itemindent 0pt}
\item\relax
\stepcounter{tipc}%
\setbox\@tempboxa\hbox\bgroup\begin{minipage}[t]{\linewidth}
{\iftip{\sc Tip}\small\else TIP\iftipno{} \tipno\fi\fi}\par\medskip\small
}{\par
\end{minipage}\egroup%
\leavevmode\label{tip-\thechapter.\arabic{tipc}}%
\tipbox
\endlist
}

定义tipbox如下。

\def\tipbox{\@tempdima\ht\@tempboxa\@tempdimb\dp\@tempboxa
\advance\@tempdimb\ht\@tempboxa
\hbox to \linewidth{\leavevmode%
\ifodd\hypergetpageref{tip-\thechapter.\arabic{tipc}}%
\else\hss\hbox{\hss
\vbox to \@tempdima{\hbox{\includegraphics{pointing-r}}\iftipno\hbox{\small\tipno}\fi\vss}~}\fi
%%% <---
\pst@divide{\@tempdima}{\@tempdimb}{\pst@tempa}%
\psshadowbox[fillcolor=lightgreen,
cornersize=absolute,linearc=1.5ex,framesep=1.5ex,boxsep=false,
linecolor=midgreen,linewidth=0.3pt,
shadowcolor=lightgrey,shadowsize=3pt,blur=true]{\unhbox\@tempboxa}%
%%% ---> 
\ifodd\hypergetpageref{tip-\thechapter.\arabic{tipc}}%
~\vbox to \@tempdima{%
\hbox{\includegraphics{pointing-l}}\iftipno\hbox to 27pt{\hss\small\tipno}\fi\vss}\hss%
\else
\hbox to 2.5em{\hss}%
\fi
}
}

使用\tipbox来自 PSTricks 的颜色定义。

\newrgbcolor{midgreen}{.9 .95 .9}%{.25 .62 .25}
\newrgbcolor{lightgreen}{.9 .95 .9}
\newgray{lightgrey}{.7}

我认为我可以 1) 将 \pst@divide{\@tempdima}{\@tempdimb}{\pst@tempa}% \psshadowbox代码替换为 TikZ 中的等效框函数和 2) 删除\newrgbcolor可以删除的 PSTriks 依赖项。

这是正确的吗?如果是这样,如何将 PSTricks 代码替换到 TikZ 中?如果不是,是否有任何简单的代码可以替换灰色框和图片中的提示环境?

可以从以下位置下载样式文件和 LaTeX 源代码进行编译https://dl.dropboxusercontent.com/u/10773282/share/2016/06/tip.zip

编辑

我可以用来xelatex编译源代码。这是过程。

运行make tfoptions.tex以获取选项文件。

删除\newif\..... \fi,并删除 book 类中的 pdftex 设置。还删除 fontenc 和 inputenc 包。

%\documentclass[10pt,\tflang,pdftex]{book}
\documentclass[10pt,\tflang]{book}
\usepackage{pst-all}
\usepackage{pst-blur}
\usepackage{pst-grad}
%\usepackage[T1]{fontenc}
%\usepackage[latin1]{inputenc}

運行make index兩次xelatex thinking-forth.tex

编辑2

用于获取封面.pdf。

删除第 8 - 14 行(\newif ... \fi),删除仅此\ifpdf而已%\else \documentclass[10pt,\tflang,dvips]{book}

创建pagecount.tex文件和\def\pagecount{306}

创建isbn.eps;转到http://smallpressbarcode.com并给出 ISBN 号978-0976458708。然后生成 eps 文件下载并将其重命名为isbn.eps

跑步latex --output=ps cover.tex; dvips cover.dvi; ps2pdf cover.ps

答案1

这是对 的首次测试tcolorbox。如果您可以考虑,可以进一步定制。

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{bbding}

\newtcolorbox[auto counter, number within=section]{mytip}%
{enhanced, width=.8\linewidth,  before upper={Tip\par}, notitle, 
 overlay={\node[align=center, text width=2cm, anchor=north west, drop fuzzy shadow] 
          at (frame.north east) {{\Huge\HandLeft}\\ \thetcbcounter};}}

\begin{document}
\begin{mytip}
tip tip tip tip tip tip
\end{mytip}


\begin{mytip}
tip tip tip tip tip tip tip tip tip tip tip tip
\end{mytip}

\end{document}

在此处输入图片描述

相关内容