3

I have a good book "Thinking Forth" which has LaTeX code availale. (http://thinking-forth.sourceforge.net)

The source code uses PSTricks, so I'm trying to remove the PSTricks dependent code. The biggest hurdle is to convert \tip environment which can be used as follows

\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}

to get this pdf results. The tip environment is smart that it shows the correct left or right finger pointing depending on the even/odd page.

enter image description here

I need to use three commands to make PSTrick code into pdf file.

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

In the tf.sty file, tip environment calls the \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
}

The tipbox is defined as follows.

\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
}
}

The \tipbox uses color definition from PSTricks.

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

I think I can 1) replace the \pst@divide{\@tempdima}{\@tempdimb}{\pst@tempa}% \psshadowbox code into equivalent box function in TikZ and 2) remove the \newrgbcolor can remove the PSTriks dependency.

Is this correct? If so, how to replace the PSTricks code into TikZ? If not, is there any easy code to replace the tip environment in gray box and pictures?

Style file and LaTeX source can be downloaded to be compiled from https://dl.dropboxusercontent.com/u/10773282/share/2016/06/tip.zip

EDIT

I could use xelatex to compile the source. This is the process.

Run make tfoptions.tex to get the option file.

Remove the \newif\.. ... \fi, and also remove the pdftex setting in book class. Also remove fontenc and inputenc package.

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

Run make index and xelatex thinking-forth.tex twice.

EDIT2

For getting the cover.pdf.

Remove the line 8 - 14 (\newif ... \fi), remove the \ifpdf to have %\else \documentclass[10pt,\tflang,dvips]{book} only.

Create pagecount.tex file and \def\pagecount{306}.

Create isbn.eps; go to http://smallpressbarcode.com and give ISBN number 978-0976458708. Then generate the eps file to download and rename it into isbn.eps.

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

  • 1
    Why do you need to convert it? I think xelatex accepts pstricks and generates pdf files. – Ignasi Jun 29 '16 at 9:40
5

This is a first test with tcolorbox. If you can consider it, it could be further customized.

\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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.