1

I want to write an exercises book for math and I don't know how to use automat numbering within the text (for example Subject 3 text, on another page Subject 4 text) without changing the formatting of the text (the number will be in line).

Thank you!

  • 1
    What exactly do you want? Inline enumeration (have a look at enumitem and paralist), sectioning, theorem like-environments with amsthm's or ntheorem's \newtheorem could be what you are looking for. – moewe Sep 5 '13 at 9:06
  • Welcome to TeX.SX! You might have a look on our our starter page if you wish to familiarize yourself further with our format. – Claudio Fiandrino Sep 5 '13 at 9:18
1

It's a bit unclear what you're looking for. Nevertheless, I'll suggest at least three ways you might automate numbering of exercises for a book.

Using the enumitem package with the inline option

This first approach requires that you load the enumitem package. Since you mention inline, I'm guessing you might want the inline feature for the enumitem package. Here's how you can set this up:

\documentclass{article}
\usepackage[inline]{enumitem}
\begin{document}

\begin{enumerate*}[label=\bfseries(\arabic*)]
\item Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae,
aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli
appellantur. Hi omnes lingua, institutis, legibus inter se differunt.
\item Gallos ab Aquitanis Garumna flumen, a Belgis Matrona et Sequana dividit.
\item Horum omnium fortissimi sunt Belgae, propterea quod a cultu atque
humanitate provinciae longissime absunt, minimeque ad eos mercatores saepe
commeant atque ea quae ad effeminandos animos pertinent important,
proximique sunt Germanis, qui trans Rhenum incolunt, quibuscum continenter
bellum gerunt. Qua de causa Helvetii quoque reliquos Gallos virtute
praecedunt, quod fere cotidianis proeliis cum Germanis contendunt, cum aut
suis finibus eos prohibent aut ipsi in eorum finibus bellum gerunt.
\item Eorum una, pars, quam Gallos obtinere dictum est, initium capit a flumine
Rhodano, continetur Garumna flumine, Oceano, finibus Belgarum, attingit
etiam ab Sequanis et Helvetiis flumen Rhenum, vergit ad septentriones.
\end{enumerate*}

\end{document}

which produces the following:

enter image description here

Defining your own counter

This next approach requires that you define your own counter and a command to both advance the counter and type set the problem number.

\documentclass{article}
\newcounter{mycurrentproblem}
\newcommand{\newproblem}{\refstepcounter{mycurrentproblem}%
  \par\noindent
  {\bfseries(\arabic{mycurrentproblem})}\hspace*{0.5em}}

\begin{document}

\newproblem Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae,
aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli
appellantur. Hi omnes lingua, institutis, legibus inter se differunt.
\newproblem Gallos ab Aquitanis Garumna flumen, a Belgis Matrona et Sequana dividit.\label{garumna.flumen}
\newproblem Horum omnium fortissimi sunt Belgae, propterea quod a cultu atque
humanitate provinciae longissime absunt, minimeque ad eos mercatores saepe
commeant atque ea quae ad effeminandos animos pertinent important,
proximique sunt Germanis, qui trans Rhenum incolunt, quibuscum continenter
bellum gerunt. Qua de causa Helvetii quoque reliquos Gallos virtute
praecedunt, quod fere cotidianis proeliis cum Germanis contendunt, cum aut
suis finibus eos prohibent aut ipsi in eorum finibus bellum gerunt.
\newproblem Eorum una, pars, quam Gallos obtinere dictum est, initium capit a flumine
Rhodano, continetur Garumna flumine, Oceano, finibus Belgarum, attingit
etiam ab Sequanis et Helvetiis flumen Rhenum, vergit ad septentriones.

In problem~\ref{garumna.flumen}, what are the names of the rivers that form the borders of Gaul?

\end{document}

This produces:

enter image description here

Using amsthm to define a theorem-like enviornment

The third approach uses the amsthm package which allows you to define a theorem-like environment.

\documentclass{article}
\usepackage{amsthm}
\newtheorem{prob}{Problem}
\begin{document}

\begin{prob}%'
  Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam
  Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur. Hi
  omnes lingua, institutis, legibus inter se differunt.
\end{prob}%'
\begin{prob}%'
   Gallos ab Aquitanis Garumna flumen, a Belgis Matrona et Sequana dividit.
\end{prob}%'
\begin{prob}%'
   Horum omnium fortissimi sunt Belgae, propterea quod a cultu atque humanitate
   provinciae longissime absunt, minimeque ad eos mercatores saepe commeant
   atque ea quae ad effeminandos animos pertinent important, proximique sunt
   Germanis, qui trans Rhenum incolunt, quibuscum continenter bellum gerunt. Qua
   de causa Helvetii quoque reliquos Gallos virtute praecedunt, quod fere
   cotidianis proeliis cum Germanis contendunt, cum aut suis finibus eos
   prohibent aut ipsi in eorum finibus bellum gerunt.
\end{prob}%'
\begin{prob}%'
   Eorum una, pars, quam Gallos obtinere dictum est, initium capit a flumine
   Rhodano, continetur Garumna flumine, Oceano, finibus Belgarum, attingit etiam
   ab Sequanis et Helvetiis flumen Rhenum, vergit ad septentriones.
\end{prob}%'

\end{document}

which results in enter image description here

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.