GeneralWant a new command similar to \subsection

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
petey
Posts: 10
Joined: Sat Feb 27, 2010 9:23 pm

Want a new command similar to \subsection

Post by petey »

Hi,

I'm writing a document that contains exercises. I want a command named \exercise that looks exactly/similar to \subsection. It should look something like this:
Exercise 1
...
Exercise 2
....
I started out using \subsection with this:

Code: Select all

\renewcommand{\thesubsection}{Exercise \arabic{subsection}}
But I also need \subsection. So I tried this:

Code: Select all

\newcounter{exercisecounter}[section]
\newcommand{\exercise}{\stepcounter{exercisecounter}\vspace{1\baselineskip}\noindent{\large\bfseries Exercise \arabic{exercisecounter}}\flushleft{}}
But it does not work the way I want it to.

Thanks in advance.
Petey

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Want a new command similar to \subsection

Post by localghost »

Perhaps you should rely on packages like exercise or something similar [1]. This seems to be easier than defining new commands (or environments).

[1] The TeX Catalogue Online, Topic Index - Typesetting Exam Scripts, Quizzes, Flashcards, and Questionnaires


Best regards and welcome to the board
Thorsten
petey
Posts: 10
Joined: Sat Feb 27, 2010 9:23 pm

Re: Want a new command similar to \subsection

Post by petey »

Thank you.

Your solution works perfectly :D. Thank you very much.
Post Reply