Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

\ifthenelse and \or

1,298 views
Skip to first unread message

Zarko F. Cucej

unread,
Jun 2, 2011, 8:50:37 PM6/2/11
to
Hi,
please consider the following example:

\documentclass{article}
\usepackage{ifthen,tikz}

\begin{document}
\begin{tikzpicture}
\draw[red,thick] (0,0) -| ++ (0.5,0.5) -| ++ (1.5,-0.5)
-| ++ (0.5,0.5) -| ++ (1.5,-0.5);
\foreach \n in {1,...,8}
{\ifthenelse{\equal{\n}{1} \or \equal{\n}{5}}
{\node[below right] at (\n/2-0.45,-1.2) {0}}
{\node[below right] at (\n/2-0.45,-1.2) {1}};
}
\end{tikzpicture}
\end{document}

I receive error: !Extra \or

What I doing wrong or is there some incompatibility between tikz and
ifthen? With \and all works fine.

Regards, zarko

Philipp Stephani

unread,
Jun 3, 2011, 1:09:20 AM6/3/11
to

Try \OR instead of \or. \or is a TeX primitive that may cause trouble
in some circumstances.

--
Change “LookInSig” to “tcalveu” to answer by mail.

GL

unread,
Jun 3, 2011, 4:57:26 AM6/3/11
to
Le 03/06/2011 02:50, Zarko F. Cucej a écrit :
> Hi,
> please consider the following example:
>
> \documentclass{article}
> \usepackage{ifthen,tikz}
>
> \begin{document}
> \begin{tikzpicture}
> \draw[red,thick] (0,0) -| ++ (0.5,0.5) -| ++ (1.5,-0.5)
> -| ++ (0.5,0.5) -| ++ (1.5,-0.5);
> \foreach \n in {1,...,8}
> {\ifthenelse{\equal{\n}{1} \or \equal{\n}{5}}
> {\node[below right] at (\n/2-0.45,-1.2) {0}}
> {\node[below right] at (\n/2-0.45,-1.2) {1}};
> }
> \end{tikzpicture}
> \end{document}
>
> I receive error: !Extra \or

Why the ifthen package ?

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw[red,thick] (0,0) -| ++ (0.5,0.5) -| ++ (1.5,-0.5)
-| ++ (0.5,0.5) -| ++ (1.5,-0.5);
\foreach \n in {1,...,8} {

\ifodd \ifnum \n =1 0 \fi \ifnum \n =5 0 \fi
1 \node[below right] at (\n/2-0.45,-1.2) {1};
\else \node[below right] at (\n/2-0.45,-1.2) {0};
\fi }

\end{tikzpicture}
\end{document}

Zarko F. Cucej

unread,
Jun 3, 2011, 4:59:43 AM6/3/11
to

Thank you very much! This work!

I looked in LaTeX companion and manual for TikZ, but I didn't find any
hint for this solution ...

Regards, Zarko

Paul Gaborit

unread,
Jun 3, 2011, 5:05:47 AM6/3/11
to

À (at) Fri, 03 Jun 2011 10:59:43 +0200,
"Zarko F. Cucej" <zarko...@google.com> écrivait (wrote):

> I looked in LaTeX companion and manual for TikZ, but I didn't find any
> hint for this solution ...

I don't understand : you have a problem with \or (from package ifthen)
but you look in LaTeX companion and manual for TikZ and not in manual
for ifthen ! ;-)

--
Paul Gaborit - <http://perso.mines-albi.fr/~gaborit/>

Zarko F. Cucej

unread,
Jun 3, 2011, 5:22:22 AM6/3/11
to
On 3.6.2011 11:05, Paul Gaborit wrote:
>
> À (at) Fri, 03 Jun 2011 10:59:43 +0200,
> "Zarko F. Cucej"<zarko...@google.com> écrivait (wrote):
>
>> I looked in LaTeX companion and manual for TikZ, but I didn't find any
>> hint for this solution ...
>
> I don't understand : you have a problem with \or (from package ifthen)
> but you look in LaTeX companion and manual for TikZ and not in manual
> for ifthen ! ;-)
>

Well, I beleive that Companion has relevant information about this and I
keep it at computer for similar cases ;-), now I will look in the manual
for ifthen too ...

regards, zarko

Zarko F. Cucej

unread,
Jun 3, 2011, 5:47:19 AM6/3/11
to

interesting solution. it works, but I have problem to understand it.
without understanding I will have difficulties to construct solution for
some other cases.

thank you very much!

regards, Zarko

Robin Fairbairns

unread,
Jun 3, 2011, 5:55:27 AM6/3/11
to
"Zarko F. Cucej" <zarko...@google.com> writes:

> On 3.6.2011 7:09, Philipp Stephani wrote:
>> "Zarko F. Cucej"<zarko...@google.com> writes:
>>>
>>> I receive error: !Extra \or
>>>
>>> What I doing wrong or is there some incompatibility between tikz and ifthen?
>>> With \and all works fine.
>>
>> Try \OR instead of \or. \or is a TeX primitive that may cause trouble
>> in some circumstances.
>
> Thank you very much! This work!

it's ridiculous that you had so much trouble finding "instruction".

the source of ifthen can be compiled to produce a little manual (which
mentions the problem with \or). it would be good if we could get that
onto ctan, but that requires discussion with the rest of the latex team,
since it's "part of" latex itself. (otoh, we supposedly have a new
version coming up, so this is an opportune moment to ask.)

of course, there _is_ a pdf of the file in
macros/latex/contrib/latex-tds/latex-tds.tds.zip but nothing on the
archive that you can just click on.

tex live has ifthen.pdf in texdoc; miktex also has it, but i don't know if
there's a neat tool for finding-and-reading it in miktex.
--
Robin Fairbairns, Cambridge
my address is @cl.cam.ac.uk, regardless of the header. sorry about that.

GL

unread,
Jun 3, 2011, 7:30:41 AM6/3/11
to
Le 03/06/2011 11:47, Zarko F. Cucej a écrit :
> On 3.6.2011 10:57, GL wrote:

>> \foreach \n in {1,...,8} {
>> \ifodd \ifnum \n =1 0 \fi \ifnum \n =5 0 \fi
>> 1 \node[below right] at (\n/2-0.45,-1.2) {1};
>> \else \node[below right] at (\n/2-0.45,-1.2) {0};
>> \fi }

>


> interesting solution. it works, but I have problem to understand it.
> without understanding I will have difficulties to construct solution for
> some other cases.

And why ?

\ifodd is the "master test" : true (odd = 1) or false (even = 0)

So: \ifodd \ifnum \n=1 0 \fi <=> if n = 1 then 0 not odd
\ifnum \n=5 0 \fi <=> if n = 5 then 0 not odd
otherwise: 1 <here 1 is odd : execute the code \ifodd is true>
\else <here is the case where \ifodd (the master test) is false>
\fi

This is an example of a nested conditional in TeX.
More complex cases can be written with \ifcase :

\ifcase <some condition is true => then> 1 (case 1) \fi
<some other condition (the first was false) then> 2 (case 2)
<some other condition (the first two were false) then> 3(case 3)
0 <here each condition were false: this is case 0 for \ifcase>
\or ... here the code for condition 1
\or ... here the code for condition 2
\or ... here the code for condition 3
etc. etc.
\fi

>
> thank you very much!
>
> regards, Zarko

Yours sincerely.


Zarko F. Cucej

unread,
Jun 3, 2011, 9:07:56 AM6/3/11
to

thank you. Now is clear!

regards, Zarko

Zarko F. Cucej

unread,
Jun 3, 2011, 9:25:35 AM6/3/11
to
On 3.6.2011 11:55, Robin Fairbairns wrote:
> "Zarko F. Cucej"<zarko...@google.com> writes:
>
>> On 3.6.2011 7:09, Philipp Stephani wrote:
>>> "Zarko F. Cucej"<zarko...@google.com> writes:
>>>>
>>>> I receive error: !Extra \or
>>>>
>>>> What I doing wrong or is there some incompatibility between tikz and ifthen?
>>>> With \and all works fine.
>>>
>>> Try \OR instead of \or. \or is a TeX primitive that may cause trouble
>>> in some circumstances.
>>
>> Thank you very much! This work!
>
> it's ridiculous that you had so much trouble finding "instruction".

I'm very sorry that I make noise on the list since I was not able to
find instruction for package ifthen.


> the source of ifthen can be compiled to produce a little manual (which
> mentions the problem with \or). it would be good if we could get that
> onto ctan, but that requires discussion with the rest of the latex team,
> since it's "part of" latex itself. (otoh, we supposedly have a new
> version coming up, so this is an opportune moment to ask.)
>
> of course, there _is_ a pdf of the file in
> macros/latex/contrib/latex-tds/latex-tds.tds.zip but nothing on the
> archive that you can just click on.

thank you for link.

> tex live has ifthen.pdf in texdoc; miktex also has it, but i don't know if
> there's a neat tool for finding-and-reading it in miktex.

I search though the MikTeX and found only .sty and .dtx file. With
compilation of .dtx I hove some problems. For resolving them I need more
time.

Thank you very much for anyone, who helped me to silve my problem.

best regards, Zarko

Lars Madsen

unread,
Jun 3, 2011, 9:28:26 AM6/3/11
to Robin Fairbairns

ifthen.pdf is provided in TeXLive 2010.

--

/daleif (remove RTFSIGNATURE from email address)

Memoir and mh bundle maintainer
LaTeX FAQ: http://www.tex.ac.uk/faq
LaTeX book: http://www.imf.au.dk/system/latex/bog/ (in Danish)
Remember to post minimal examples, see URL below
http://www.minimalbeispiel.de/mini-en.html

GL

unread,
Jun 3, 2011, 10:24:37 AM6/3/11
to

What about:
http://www.google.co.uk/search?sourceid=chrome&ie=UTF-8&q=ifthen+site%3Atex.ac.uk

google.co.uk : query : "ifthen site:tex.ac.uk"

This works fine with MiKTeX ;-)

Robin Fairbairns

unread,
Jun 3, 2011, 11:08:52 AM6/3/11
to
"Zarko F. Cucej" <zarko...@google.com> writes:

> On 3.6.2011 11:55, Robin Fairbairns wrote:
>> it's ridiculous that you had so much trouble finding "instruction".
>
> I'm very sorry that I make noise on the list since I was not able to
> find instruction for package ifthen.

i was *not* complaining -- but rather speculating how we might make it
easier to find. ((la)tex is difficult enough if you have access to the
documentation; if you can't find documentation you can become *really*
confused.

i don't know about miktex and documentation, though: i've not used for
quite a while, and i've just set one of my windoze boxes updating its
miktex from 2.6(!) to current 2.9; miktex 2.6 seems not to have anything
analogous to the tex live "texdoc".

>> of course, there _is_ a pdf of the file in
>> macros/latex/contrib/latex-tds/latex-tds.tds.zip but nothing on the
>> archive that you can just click on.
>
> thank you for link.

i don't think it's terribly useful, in this context... (on reflection,
anyway.)

> Thank you very much for anyone, who helped me to silve my problem.

my real concern is that you don't find yourself in this situation again:
this sort of problem is why i started writing the faq (in 1994). the
faq can help with quite a few things, but not ifthen (or even the plain
tex stuff that gl was banging on about). i'll write something about
that ... some time ... it's now on the "to do" list, but the list was
awfully long even without it.

Robin Fairbairns

unread,
Jun 3, 2011, 11:14:03 AM6/3/11
to
Lars Madsen <dal...@RTFMSIGNATUREimf.au.dk> writes:

> Robin Fairbairns wrote, On 2011-06-03 11:55:

>> ["Zarko F. Cucej" <zarko...@google.com> writes:]


>> tex live has ifthen.pdf in texdoc; miktex also has it, but i don't know if
>> there's a neat tool for finding-and-reading it in miktex.
>
> ifthen.pdf is provided in TeXLive 2010.

as i said. it's also in miktex, which zarko uses, but it looks as if
you have to "know" that sort of thing, to be able to use it in miktex.

(i would welcome being told that i'm wrong about this: miktex's mostly
pretty neat, afaict.)

Robin Fairbairns

unread,
Jun 3, 2011, 11:20:43 AM6/3/11
to
GL <goua...@gmail.com> writes:

sure, but it doesn't get you to any documentation of ifthen; xifthen, it
helps with, but ifthen ... nah.

note that, apart from writing faq answers, i doubt i use ifthen any more
than gl does.

Ulrich D i e z

unread,
Jun 3, 2011, 8:11:08 PM6/3/11
to
Robin Fairbairns wrote:

> i don't know about miktex and documentation, though: i've not used for
> quite a while, and i've just set one of my windoze boxes updating its
> miktex from 2.6(!) to current 2.9; miktex 2.6 seems not to have anything
> analogous to the tex live "texdoc".

I have a program called texdoc both on MiKTeX 2.4
and on MiKTeX 2.9.

I don't know of it is the same as the tex live "texdoc".

Both with MiKTeX 2.4 and MiKTeX 2.9 it is to be used
from the command-prompt.

When typing, e.g., "texdoc ifthen" on the command-prompt,
then the internet-browser pops up, showing the content
of some html-file containing documentation about the
ifthen-package written in a language which I do not
understand and which is stored locally on the hard-disk.

When typing, e.g., "texdoc graphics" on the command-prompt,
then the internet-browser pops up, showing the content
of some html-file which is stored locally on the hard-disk.
and which contains a linked list to files (pdf-files,
postscript-files) also stored on the hard-disk, containing
information about the graphics-package in english language.

Sincerely

Ulrich

GL

unread,
Jun 4, 2011, 3:05:39 AM6/4/11
to

Yes I tried it. The html page is in polish language !
Anyway I've better tools to find the local documentation files.

But I still insist that the simplest tool - which is easy to implement
as a macro for any text editor that supports macros - is to query

"http://www.tex.ac.uk/tex-archive/help/Catalogue/entries/"
+ "ifthen" + ".html"

But it's weird that this package does not provide the documentation
from this "home page"...


As Robin said, the best is not to use ifthen at all. I'm absolutely
fully completely convinced that ifthen is useless in all cases.


> Sincerely
>
> Ulrich

Robin Fairbairns

unread,
Jun 4, 2011, 4:27:21 AM6/4/11
to
GL <goua...@gmail.com> writes:

> Le 04/06/2011 02:11, Ulrich D i e z a écrit :
>> Robin Fairbairns wrote:
>>
>>> i don't know about miktex and documentation, though: i've not used for
>>> quite a while, and i've just set one of my windoze boxes updating its
>>> miktex from 2.6(!) to current 2.9; miktex 2.6 seems not to have anything
>>> analogous to the tex live "texdoc".
>>
>> I have a program called texdoc both on MiKTeX 2.4
>> and on MiKTeX 2.9.

ooh. so do i -- just no gui means of access. i was blindly looking for
a gui (switching my brain to windows mode) and didn't find one. i don't
have a current miktex here (and i'm not about to install one, given that
my home ctan mirror doesn't even offer services over my home lan).

>> I don't know of it is the same as the tex live "texdoc".

could well be. iirc, current tl texdoc is written in lua, so porting
would be dead easy.

>> Both with MiKTeX 2.4 and MiKTeX 2.9 it is to be used
>> from the command-prompt.
>>
>> When typing, e.g., "texdoc ifthen" on the command-prompt,
>> then the internet-browser pops up, showing the content
>> of some html-file containing documentation about the
>> ifthen-package written in a language which I do not
>> understand and which is stored locally on the hard-disk.
>>
>> When typing, e.g., "texdoc graphics" on the command-prompt,
>> then the internet-browser pops up, showing the content
>> of some html-file which is stored locally on the hard-disk.
>> and which contains a linked list to files (pdf-files,
>> postscript-files) also stored on the hard-disk, containing
>> information about the graphics-package in english language.
>
> Yes I tried it. The html page is in polish language !
> Anyway I've better tools to find the local documentation files.

there's a lot of polish documentation. once upon a time there was a
project to translate documentation to french, too -- but that seems to
have stalled :-(

> But I still insist that the simplest tool - which is easy to implement
> as a macro for any text editor that supports macros - is to query
>
> "http://www.tex.ac.uk/tex-archive/help/Catalogue/entries/"
> + "ifthen" + ".html"
>
> But it's weird that this package does not provide the documentation
> from this "home page"...

it's not a home page, it's an entry in a catalogue.

as i said, the only documentation (in tl) seems to have been pulled for
latex-tds (or something). there is nothing i can refer to, from the
catalogue, so there ain't a reference.

> As Robin said, the best is not to use ifthen at all. I'm absolutely
> fully completely convinced that ifthen is useless in all cases.

i certainly didn't intend to say that (and i don't recall saying that,
but no matter). i _did_ say that i don't use the package myself. if
one started using plain tex (as many of us, who started before the web
was invented, did), one learnt tex primitive conditionals.

that's ok for us, but there are those who struggle with programming
syntax of any kind. the idea of ifthen.sty was to support the person
who didn't want to learn a different syntax, having started with latex.
it meets that need, but it really _ought_ to have some documentation
available on the web.

rsh

unread,
Jun 4, 2011, 10:00:41 AM6/4/11
to
On Jun 3, 5:14 pm, Robin Fairbairns <r...@sxp10.cl.cam.ac.uk> wrote:
> Lars Madsen <dal...@RTFMSIGNATUREimf.au.dk> writes:
> > Robin Fairbairns wrote, On 2011-06-03 11:55:
> >> ["Zarko F. Cucej" <zarko.cu...@google.com> writes:]

> >> tex live has ifthen.pdf in texdoc; miktex also has it, but i don't know if
> >> there's a neat tool for finding-and-reading it in miktex.
>
> > ifthen.pdf is provided in TeXLive 2010.
>
> as i said.  it's also in miktex, which zarko uses, but it looks as if
> you have to "know" that sort of thing, to be able to use it in miktex.
>
> (i would welcome being told that i'm wrong about this: miktex's mostly
> pretty neat, afaict.)
> --
> Robin Fairbairns, Cambridge
> my address is @cl.cam.ac.uk, regardless of the header.  sorry about that.

With miktex, you can use the "run command" in Window$ (if you have W7
or Vista, just tap the windows-buttom) and write:

mthelp --view ifthen

Assuming that you have "miktex\bin" in your path (which is default
installation).

Sveinung

Ulrich D i e z

unread,
Jun 4, 2011, 11:14:28 AM6/4/11
to
rsh wrote:

> With miktex, you can use the "run command" in Window$ (if you have W7
> or Vista, just tap the windows-buttom) and write:
>
> mthelp --view ifthen
>
> Assuming that you have "miktex\bin" in your path (which is default
> installation).
>
> Sveinung

Using Windows 7, you can also launch a command-prompt-
window via "cmd.exe" both for calling mthelp and for
calling texdoc.
(On the machine used by me the path is
"C:\Windows\System32\cmd.exe". )

Ulrich

0 new messages