0

See the code given below. Actually, I am looking for a tree of number 36.

Can somebody let me know what I did wrong?

\documentclass[12pt, a4paper]{article}
\usepackage[a4paper,top=1 in,bottom=1 in,left=0.7 in,right=0.7 in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[misc]{ifsym}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pst-tree}
\psset{levelsep=1,treesep=1,nodesep=2pt}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{lastpage}
\lhead{}
\rhead{}
\chead{}
\rfoot{Page \thepage \hspace{1pt} of \pageref{LastPage}}
\lfoot{}
\cfoot{}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\begin{document}
\preview
\psTree{\TR{36}}
\Tcircle{2}
\psTree{\TR{18}}
\Tcircle{2}
\psTree{\TR{9}}
\Tcircle{3}
\Tcircle{3}
\endpsTree
\endpsTree
\endpsTree
\endpreview
\end{document}
  • I don't really understand, the only thing preventing that code from running is \preview and \endpreview. They presumably come from the preview package, which you don't load, but I don't think you would need it here anyway. If you remove those two lines, does it work for you? If not, can you tell us which error message you get, or otherwise what the problem is? – Torbjørn T. Jan 23 '16 at 8:16
  • Just a minute i am sending the errors. – Maths4Sandy Jan 23 '16 at 8:18
  • line 24: Undefined control sequence. \preview – Maths4Sandy Jan 23 '16 at 8:22
  • As I said, does it work if you remove \preview and \endpreview? – Torbjørn T. Jan 23 '16 at 8:23
  • 1
    Hi snehal. I think we're going to 'close' this question for the moment, but this does not mean you won't get an answer. Once you've cleaned up the original question with all (or most) of the needed information, I'll nominate the question for re-opening myself. In its current form, a good answer to your question simply isn't possible (largely because the question itself is unclear). – Sean Allred Jan 23 '16 at 13:44
2

My crystal ball reports that the first error you got is

! Undefined control sequence.
<recently read> \c@lor@to@ps 

then multiple errors of the form

! Undefined control sequence.
\XC@usec@lor ...string \color@ #1#2\endcsname \@@ 
                                                  \fi \space 
l.25 \Tcircle{2}

Tcircle here is just the location of the error (line 25) the undefined command is \@@ but always with TeX it is best to ignore all but the first error.

You are using pstricks which requires latex and dvips, not pdflatex. If you use pdflatex you get the errors shown,

The posted code, if used with latex, runs without error, then you need to use dvips and ps2pdf to get PDF output.

  • If this is right then the question is a dupe ... – Joseph Wright Jan 24 '16 at 11:34
2

Do not use the environment preview. Use package auto-pst-pdf and the environment postscript instead if you run it with pdflatex --shell-escape <file>:

\documentclass[12pt, a4paper]{article}
\usepackage[a4paper,top=1 in,bottom=1 in,left=0.7 in,right=0.7 in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[misc]{ifsym}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{auto-pst-pdf}
\ifpdf
  \usepackage{tikz}
\else
  \usepackage{pst-tree}
  \psset{levelsep=1,treesep=1,nodesep=2pt}
\fi

\begin{document}
\begin{postscript}
    \psTree{\TR{36}}
    \Tcircle{2}
    \psTree{\TR{18}}
    \Tcircle{2}
    \psTree{\TR{9}}
    \Tcircle{3}
    \Tcircle{3}
    \endpsTree
    \endpsTree
    \endpsTree
\end{postscript}
\end{document}

Using xelatex instead of pdflatex makes life easier. Then you do not need package auto-pst-pdf and the environment postscript:

\documentclass[12pt, a4paper]{article}% xelatex <file>
\usepackage[a4paper,top=1 in,bottom=1 in,left=0.7 in,right=0.7 in]{geometry}
\usepackage[misc]{ifsym}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{fontspec}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pst-tree}
\psset{levelsep=1,treesep=1,nodesep=2pt}

\begin{document}
    \psTree{\TR{36}}
    \Tcircle{2}
    \psTree{\TR{18}}
    \Tcircle{2}
    \psTree{\TR{9}}
    \Tcircle{3}
    \Tcircle{3}
    \endpsTree
    \endpsTree
    \endpsTree

\end{document}

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.