Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language LaTeX2e

Date:04/20/05
Author:Anonymous
URL:n/a
Comments:2
Info:n/a
Score: (3.40 in 35 votes)
% LaTeX2e-Version
% (th-beer@square.de), 2002-01-11

\documentclass{article}
\usepackage{ifthen}
\parindent 0 pt
\parskip 1.5 ex

\newcounter{beers}\setcounter{beers}{99}

\begin{document}
\whiledo{\value{beers}>1}{%
	\thebeers\ Bottles of beer on the wall, \thebeers\ bottles of beer\\
	Take one down and pass it around,\\
	\addtocounter{beers}{-1}\thebeers\ %
	\ifthenelse{\equal{\thebeers}{1}}{bottle}{bootles} 
	of beer on the wall.\par
}
\whiledo{\value{beers}>0}{%
	\thebeers\ Bottle of beer on the wall, \thebeers\ bottle of beer\\
	Take one down and pass it around,\\
	\addtocounter{beers}{-1}no bootles of beer on the wall.\par
}
\end{document}

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
corrected & updatedDavid Short08/07/080
Uses only pgf commands and fmtcountJoel Berger04/19/101

Comments

>>  Romwell said on 10/01/06 22:38:12

Romwell Oh, that is so cute ! I can even execute it without having to start anything, since I just happened to have TeXnic Center open :) It works !

For those of you who don't know, LaTeX is a markup language, sort of like HTML, only extremely more powerful (like HTML vs Plain Text). It is used industrially to typeset books and scientific articles. It's easy enough to be learned by casual users though, and it's so much easier to type mathematics in it than in anything else (i.e. Word).

>>  David Short said on 08/07/08 03:52:36

David Short Great stuff, but a pity about the mistakes.

The capitalisation is wrong.
You have "bootle" for "bottle".
The final part about going to the store for more is missing.

Download Source | Write Comment

Add Comment

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.

Please don't post large portions of code here! Use the form to submit new examples or updates instead!

Name:

eMail:

URL:

Security Code:
  
Comment: