0

I am tryting to learn Latex using the not so short introduction to latex. But I am having trouble reproduce one of the example from the book.

Here is my code

documentclass{article}
\usepackage{ifthen}
\ifthenelse{\equal{\blackandwhite}{true}}{
%"black and white"mode;do something..}
{%"color" mode; do something different...
}

\usepackage{pgf}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=3]
 \clip (-0.1,-0.2)
    rectangle(1.8,1.2);
 \draw[step=.25cm,gray,very thin]
      (-1.4,-1.4) grid (3.4,3.4);
\draw (-1.5, 0) --(2.5,0);
 \draw(0,-1.5)--(0,1.5);
 \draw (0,0) circle (1cm);
 \filldraw[fill=green!100!black,draw=green!50!black]
 (0,0)--(3mm,0mm)
    arc (0:30:3mm)--cycle;t
 \end{tikzpicture}

\end{document}` 

and here is my command line input under terminal terminal image I admit I don't actually know what I am doing. I am merely trying to quickly skim through the book to have a rough idea of what Latex is capable of, and I will figure out the detail when I need it later. So excuse me if this is a very elementary mistake that I made.

jxhyc
  • 1,121
  • You are setting commands on the commandline which is possible but a rare and somewhat advanced use and the details depend on the operating system commandline syntax. Also these days most people use pdflatex rather than latex so get a pdf file that is immediately usable – David Carlisle Apr 23 '20 at 09:56
  • 1
    your actual error is that you need a } on the line after %"black and white"mode;do something..} as the } on that line has been commented out, but this is just a dummy code that you could delete it says: if blackandwhite do nothing else do nothing. – David Carlisle Apr 23 '20 at 09:59

1 Answers1

1

The error is a missing } (or at least a commented out }) in

\ifthenelse{\equal{\blackandwhite}{true}}{
%"black and white"mode;do something..}
{%"color" mode; do something different...
}

so you could do

\ifthenelse{\equal{\blackandwhite}{true}}{
%"black and white"mode;do something..
}
{%"color" mode; do something different...
}

but this is just a dummy test that does nothing at all in both of the branches. So it would be simpler (and better) to delete the test and simply have

\documentclass{article}

\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=3]
 \clip (-0.1,-0.2)
    rectangle(1.8,1.2);
 \draw[step=.25cm,gray,very thin]
      (-1.4,-1.4) grid (3.4,3.4);
\draw (-1.5, 0) --(2.5,0);
 \draw(0,-1.5)--(0,1.5);
 \draw (0,0) circle (1cm);
 \filldraw[fill=green!100!black,draw=green!50!black]
 (0,0)--(3mm,0mm)
    arc (0:30:3mm)--cycle;t
 \end{tikzpicture}

\end{document}

save it as document.tex then use a simple comandline

pdflatex document

rather than the tricky form that you are using with

latex '\newcommand\blackandwhite{true} \input{document}'
David Carlisle
  • 757,742