Document Classespdflatex pstricks pagelayout

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
suren
Posts: 12
Joined: Mon Mar 04, 2013 11:47 pm

pdflatex pstricks pagelayout

Post by suren »

Well, I hope I am not posting something that has already been posted.
Here is the problem:
I need to generate a document in booklet form (for duplex printing). The document will be printed on an a4 paper in landscape. Each half of the paper will carry an individual page ( you can call it signature)

To get the result I used a script which someone has posted on the net. The script works absolutely fine. However, when I use pstricks, everything fails. I used pstricks to produce figures (geometrical figures: e.g. pstriangle).

The sample code is as below

The script for generating the document:

Code: Select all

#===============================================
#!/bin/sh
#
# This script takes an A5 latex file as input and produces an A4
# document (both ps and pdf) for printing an A5 booklet
#
# Usage:
# booklet [filename without extension]

latex $1
latex $1

# make an a5 ps from dvi:
dvips -t a5 -o $1.ps $1.dvi

# sort pages
psbook $1.ps tmp1.ps

# put two pages on one a4 sheet
psnup -Pa5 -pa4 -2 tmp1.ps tmp2.ps

# change a5 to a4 in ps file
sed 's/^%%DocumentPaperSizes: A5/%%DocumentPaperSizes: a4/g' < tmp2.ps > $1_booklet.ps

# produce pdf files, pdflatex ist used (twice) to get bookmarks
pdflatex $1.tex
pdflatex $1.tex
ps2pdf -sPAPERSIZE=a4 $1_booklet.ps

# delete tmp files
rm tmp1.ps tmp2.ps
#===============================================
1. The document 1(without using pstricks)

Code: Select all

\documentclass[a5paper,headsepline,titlepage,10pt,normalheadings,DIVcalc]{scrartcl}
\usepackage[a5paper,backref]{hyperref}
\usepackage{ngerman}
\usepackage{xspace}
\usepackage{graphicx}
\usepackage{picinpar}
\usepackage{epsfig}
\begin{document}%
    \begin{itemize}
        \item line 1
        \item line 2
        \item line 3
        \item line4
    \end{itemize}
\end{document}
----
2. The document 1(using pstricks)

Code: Select all

\documentclass[a5paper,headsepline,titlepage,10pt,normalheadings,DIVcalc]{scrartcl}
\usepackage[a5paper,backref]{hyperref}
\usepackage{ngerman}
\usepackage{xspace}
\usepackage{pstricks}
\usepackage{graphicx}
\usepackage{picinpar}
\usepackage{epsfig}
\begin{document}%
    \begin{itemize}%
        \item line 1
        \item line 2
        \item line 3
        \item line4
    \end{itemize}%
%
\begin{pspicture}(3,3)
    \pstriangle[gangle=180](1.5,2.5)(3,2.5)
    \psdot(1.5,1.5)
\end{pspicture}
\end{document}%
%----------------------------------------------
Conclusion:
1. if I do not use pstricks, everything goes fine
2. if I use pstricks, no pdf file is generated

What is the work around?
How can I use pstricks?

(Please note: I am not an expert, but a self taught person.)



Thank you in advance
Suren
Last edited by cgnieder on Tue Mar 05, 2013 12:43 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
suren
Posts: 12
Joined: Mon Mar 04, 2013 11:47 pm

Re: pdflatex pstricks pagelayout

Post by suren »

I hope, somebody could give me a solution.
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

pdflatex pstricks pagelayout

Post by Juanjo »

I think that the problem comes from the two lines pdflatex $1.tex that you'll see near the bottom in the script. Suppose that your source file is called foo.tex. First, it is compiled twice, so you get foo.dvi, with cross-references correctly settled. The successive commands dvips, psbook, psnup and sed yield the booklet in postscript form (file foo_booklet.ps). For printing, you only need a pdf file of the booklet. This is achieved by the ps2pdf command. But you don't need a pdf file of the original document. Hence the above cited lines are superfluous; in fact, that second compilation of foo.tex is not compatible with the use of postscript and hence the script breaks.

Summarizing, edit the script and remove or comment out those lines. For testing purposes, save the following code in foo.tex:

Code: Select all

\documentclass[a5paper,headsepline,titlepage,10pt,headings=normal,DIV=calc]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage{xspace}
\usepackage{pstricks}
\usepackage{graphicx}
\usepackage{picinpar}
\usepackage{lipsum}
\usepackage[backref]{hyperref}

\begin{document}

\section{First section}

\begin{itemize}
   \item line 1
   \item line 2
   \item line 3
   \item line4
\end{itemize}

\begin{pspicture}(3,3)
    \pstriangle[gangle=180](1.5,2.5)(3,2.5)
    \psdot(1.5,1.5)
\end{pspicture}

\lipsum[1-20]

\section{Second section}

\lipsum[21-40]

\end{document}
The script, once edited, works fine and yields the attached pdf file. Please note the changes in the preamble. You were using an outdated template.
Attachments
foo_booklet.pdf
(55.17 KiB) Downloaded 497 times
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
suren
Posts: 12
Joined: Mon Mar 04, 2013 11:47 pm

pdflatex pstricks pagelayout

Post by suren »

Thank you very much, Juanjo. That is a lovely solution. Now that problem is solved.
I have a problem with the same shell script but in a different environment.
As I am working on a project that involves the usage of my mother tongue Malayalam, I am using a package called "malayalam". It is, I think, in the standard installation.

Usage: this package requires the use of a pre-processor called "mal" .
The initial document is written just as a text file but saved not with a *.tex extension but with *.mm . The file is processed using the pre-processor with an option (font option)
Which generates a *.tex file. The resulting *.tex file is then processed as usual. I did this using the same shell script. For some reason, the compiling fails. The strange thing is, a few months back I compiled a document successfully. Apparently after an update, (TeXLive 2012) It does not seem to work. The fault, however, may lie on my side.

Here is the work flow:

1. initial file saved as foo.mm
2. pre-processor: mal foo.mm rachana (rachana is the font option.
3. result: foo.tex
4. the shell script

Here is a sample:

Code: Select all

\documentclass[a5paper,headsepline,titlepage,10pt,headings=normal,DIV=calc]{scrartcl}
\usepackage[backref]{hyperref}
\usepackage[rachana]{malayalam}
\usepackage{xspace}
\usepackage{pstricks}
\usepackage{graphicx}
\usepackage{picinpar}
%
\begin{document}
%
<m>surEn</m> % this will write my name in Malayalam letters
%
\end{document}

The shell script is the same as the one in my first post. I tried removing the two lines of pdflatex. No success. Additionally there is even an font error. This font error does not occur if use the simple processing (pdflatex foo.tex)

Apparently there is a postscript error. A *.dvi file is created. Hence, but no postscript.

Thank you in advance
Best regards
suren
Last edited by cgnieder on Thu Mar 07, 2013 8:29 pm, edited 1 time in total.
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

pdflatex pstricks pagelayout

Post by Juanjo »

The malayalam bundle is not part of TeX Live, so I cannot test it and help you to solve issues with your language. Sorry. It seems however that typesetting should be possible through the long route (latex+dvips+ps2pdf), since there are some examples with pstricks in the malayalam bundle, downloadable here. Perhaps you should reinstall it.

Let us assume the worst scenario, i.e. that you can't typeset malayalam texts through latex+dvips, only with pdflatex. In this case, you cannot longer use the script nor PStricks. But I think it will be possible to find workarounds. For the graphics, you can make them in a separate document, convert to pdf and include them in the appropriate places. You can also make them with the picture environment, if they are simple, or the Tikz package. Concerning booklets, there exists the booklet package.
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
suren
Posts: 12
Joined: Mon Mar 04, 2013 11:47 pm

Re: pdflatex pstricks pagelayout

Post by suren »

Thank you very much. I shall have a look at the booklet package. It does sound interesting.

Best regards
suren
Post Reply