Text FormattingHaving a dot after number of algorithm

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
krasnal1988
Posts: 8
Joined: Tue May 10, 2011 10:31 pm

Having a dot after number of algorithm

Post by krasnal1988 »

I have small problem with numbering. Of course I use code from this topic

http://www.latex-community.org/forum/vi ... 703#p49703

Code: Select all

\def\@seccntformat#1{\csname the#1\endcsname.\quad}
\def\numberline#1{\hb@xt@\@tempdima{#1\if&#1&\else.\fi\hfil}}
In my document I use algorithm environment. Every algorithm has number of section and number of algorithm eg. "Algorithm 3.1". I want add dot after last number eg. "Algorithm 3.1.". If I use

Code: Select all

\renewcommand{\thealgorithm}{\thesection.{\arabic{algorithm}.}}
I'll get what i want, but in list of algorithms i have double dot ("3.1.. Algorithm of...")

How to solve this problem?

This is my preamble

Code: Select all

\documentclass[12pt,a4paper,titlepage]{article}

\usepackage[utf8]{inputenc}
\usepackage{amsfonts,amssymb,amsthm,amsmath}
\usepackage[english,polish]{babel}
\usepackage[OT4]{fontenc}
\usepackage[plmath]{polski}
\usepackage[section]{algorithm} 
\usepackage{caption,algpseudocode}

\numberwithin{equation}{section}
\renewenvironment{proof}[1][Dowód]{\noindent\textbf{#1.} }{\ \rule{0.5em}{0.5em}}

\makeatletter
 \def\imod#1{\allowbreak\mkern10mu({\operator@font mod}\,\,#1)}
 \def\@seccntformat#1{\csname the#1\endcsname.\quad}
 \def\numberline#1{\hb@xt@\@tempdima{#1\if&#1&\else.\fi\hfil}}
 \makeatother

\begin{document}
PS. Thank you Stefan

Recommended reading 2024:

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

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

User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Having a dot after number of algorithm

Post by sommerfee »

The command responsible for typesetting the caption label of the algorithm environment is \fnum@algorithm. The original definition is something like

Code: Select all

\newcommand\fnum@algorithm{\fname@algorithm~\thealgorithm}
so the solution is redefining it (within the \makeatletter...\makeatother block):

Code: Select all

\renewcommand\fnum@algorithm{\fname@algorithm~\thealgorithm.}% <= with dot at the end
HTH,
Axel
krasnal1988
Posts: 8
Joined: Tue May 10, 2011 10:31 pm

Having a dot after number of algorithm

Post by krasnal1988 »

Hi!

Thank you :) it works. I have one more similar problem. Or two. I add also

Code: Select all

\numberwithin{table}{section}
and number of table looks like "Table 3.1: Table of...". How change ":" to dot?

PS. How change "Table" to other word eg. "Matrix"? And change "List of table" to "List of Matrixes"?
User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Having a dot after number of algorithm

Post by sommerfee »

krasnal1988 wrote:number of table looks like "Table 3.1: Table of...". How change ":" to dot?

Code: Select all

\usepackage[labelsep=period]{caption}
PS. How change "Table" to other word eg. "Matrix"? And change "List of table" to "List of Matrixes"?
One could either redefine \tablename and \listtablename, or define a new floating environment, e.g.:

Code: Select all

\documentclass{article}

\usepackage[labelsep=period]{caption}
\DeclareCaptionType{Matrix}[Matrix][List of Matrixes]

\begin{document}

\listofMatrixs

\begin{Matrix}
% ...
\caption{An invisible matrix}
\end{Matrix}

\end{document}
krasnal1988
Posts: 8
Joined: Tue May 10, 2011 10:31 pm

Re: Having a dot after number of algorithm

Post by krasnal1988 »

Thank you so much. I'm going to work on my project ;)
Post Reply