Text Formatting\subsubsection counter

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

\subsubsection counter

Post by svend_tveskaeg »

Hi LaTeX friends.

I'm typing exercises using the \subsubsection command, e.g.,

Code: Select all

\subsubsection{Exercise~1}
\label{exc:1}
This is exercise~\label{exc:1}.
Typing this I get ``This is exercise x.x.1.'' instead of ``This is exercise 1.''

How do I get the latter of the two?

Thanks in advance!
Last edited by cgnieder on Tue Oct 09, 2012 12:48 pm, edited 1 time in total.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)

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

php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm

\subsubsection counter

Post by php1ic »

You can define a new counter for your exercises

Code: Select all

\documentclass{article}
\begin{document}
\newcounter{exer}

\subsubsection{Exercise~1}\label{ex:1}
\stepcounter{exer}

This is subsubsection~\ref{ex:1} but exercise~\arabic{exer} within

\subsubsection{Exercise~2}\label{ex:2}
\stepcounter{exer}

This is subsubsection~\ref{ex:2} but exercise~\arabic{exer} within
\end{document}
It is discussed in more detail here

http://en.wikibooks.org/wiki/LaTeX/Advanced_Topics
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Re: \subsubsection counter

Post by svend_tveskaeg »

Thank you, very much!
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
karlisrepsons
Posts: 50
Joined: Sat May 23, 2009 10:13 pm

\subsubsection counter

Post by karlisrepsons »

Hey, check this idea out:

Code: Select all

{\renewcommand{\thesubsubsection}{\arabic{subsubsection}.}\thesubsubsection}
\thesubsubsection
Its better in the sense you won't have to create any new counters!
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Re: \subsubsection counter

Post by svend_tveskaeg »

Thanks to both of you!


Another problem:
Can someone tell me why the attached file won't compile? :? (I'm using TeX Live 2009 on an Ubuntu 9.10 machine.)

I have tried to follow the example on page 151 in The LaTeX Companion, 2nd Edition.
Attachments
test.tex
(1.02 KiB) Downloaded 376 times
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
karlisrepsons
Posts: 50
Joined: Sat May 23, 2009 10:13 pm

\subsubsection counter

Post by karlisrepsons »

Well, to me there were at least two problems:
1. unicode input;
2. somewhat crazy use of list environment.

Sorry if you don't have XeTeX, but I wrote it for that + you'll have to figure out, if you really need that kind of environment as you tried to. Look:

Code: Select all

\documentclass[a4paper,12pt]{article}
\usepackage[danish]{polyglossia}
\usepackage{mathtools}

\begin{document}

\tableofcontents

\section{Du får oplyst at cirklens omkreds kan beregnes ved formlen}
\begin{equation}
 \label{omkreds1}
  O = \pi \cdot d = 3{,}14 \cdot d,
\end{equation}
hvor $\pi$ \emph{altid} har værdien $3{,}14$. Din opgave er nu at
udregne cirlens omkreds $O$, når det oplyses at diametren er $d = 3$.
\label{opg:1}

\section{En anden formel for cirklen omkreds er}
\begin{equation}
 \label{omkreds2}
  O = 2 \cdot \pi \cdot r.
\end{equation}
Nu skal du måle $r$ på figuren [som ikke er indtegnet i opgaveformuleringen
endnu] og så bruge formel~\eqref{omkreds2} til at beregne omkredsen
$O$.\label{opg:2}

\end{document}
Seemed ok to me, but I'm Latvian and not you :)
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

\subsubsection counter

Post by svend_tveskaeg »

(1) My enconding is [update: not] fine. [Update: You are right but it is now fixed.]
(2) I would like an environment like the one I've tried to put together in the attached file. [Update: I have figured out the problems.]

[Update: Thanks to you all!]
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
Post Reply