I've got an algorithm to send tomorrow, and I've got a problem in LaTeX.
Here is my algorithm, and, after putting a picture after my algorithm (which is well displayed, even if LaTeX gives me some errors), I receive lots of bizarre errors!
I've also put a Minimum Working Example, but the CODE section does not want to end, because of my code

Thanks!
Code: Select all
\begin{breakalgo}
\begin{algorithm}
%\caption{Algorithme de la JT-Figure}
\begin{algorithmic}[1]
%%-----------------------------------------------
\STATE \{$P:((p\geq 0)\and (pmax\geq 0)\and (i\geq 0)\and (j\geq 0))$\}
\STATE BEGIN
\STATE $pmax:=0$;
\STATE $p:=1$;
\STATE $i,j:=0$;
\WHILE{$i<M$}
\IF{$j=N-1$}
\STATE $i:=i+1$;
\STATE $j:=0$
\ENDIF
\IF{not($j=(N-1)$)}
\IF{(\not($B[i,j]$))}
\STATE $p:=0$
\ENDIF
\WHILE{$orig=true$}
\IF{($B[i,j]$)}
\STATE $p:=p+1$;
\STATE $comp:=0$;
\STATE $k:=p-1$;
\WHILE{$(comp< (2k+1))$}
\WHILE{($B[i+k,comp]$) \and ($comp< (2k+1)$)}
\STATE $nb:=nb+1$;
\STATE $comp:=comp+1$
\ENDWHILE
\WHILE{(\not($B[i+k,comp]$))\and ($comp <(2k+1)$)}
\STATE $comp:=comp+1$
\ENDWHILE
\ENDWHILE
\STATE $comp:=2$;
\WHILE{$comp< (2k+1)$}
\WHILE{($B[i+k-1,comp]$)}
\STATE $nbdeux:=nbdeux+1$;
\STATE $comp:=comp+1$
\ENDWHILE
\WHILE{(\not($B[i+k-1,comp]$)\and ($comp<(2k+1)$))}
\STATE $comp:=comp+1$
\ENDWHILE
\IF{($nb>nbdeux$)}
\STATE $pmax:=pmax+1$;
\STATE $orig:=true$
\ENDIF
\IF{$nb\leq nbdeux$}
\STATE $orig:=false$
\ENDIF
\ENDWHILE
\ENDIF
\ENDWHILE
\ENDIF
\STATE $j:=j+1$
\ENDWHILE
\WHILE{($i<M$)}
\IF{($j=N-1$)}
\STATE $i:=i+1$;
\STATE $j:=0$
\ENDIF
\IF{\not($j=N-1$)}
\IF{\not($B[i,j]$)}
\STATE $p:=0$
\ENDIF
\IF{$B[i,j]$}
\STATE $l:=0$;
\WHILE{($l< pmax$)}
\STATE $m:=i$;
\STATE $n:=j$;
\WHILE{($m<M$)}
\IF{($n=N-1$)}
\STATE $m:=m+1$;
\STATE $n:=0$;
\STATE $l:=l+1$
\ENDIF
\STATE $n:=n+1$;
\STATE $l:=l+1$
\ENDWHILE
\ENDWHILE
\ENDIF
\STATE $nbel:=nbel+1$;
\IF{$pmax>1$}
\STATE $new(lst)$;
\STATE $lst\uparrow .info:=m$;
\STATE $lst\uparrow .next:=n$;
\STATE $n:=m$;
\ENDIF
\ENDIF
\STATE $j:=j+1$
\ENDWHILE
\IF{$pmax\leq 1$}
\STATE $m:=0$;
\STATE $n:=0$;
\STATE $new(lst)$;
\STATE $lst\uparrow .info:=m$;
\STATE $lst\uparrow .next:=n$;
\ENDIF
\STATE END.
\end{algorithmic}
\end{algorithm}
\end{breakalgo}
Code: Select all
%%% francisation des algorithmes
\renewcommand{\algorithmicrequire} {\textbf{\textsc{Entrées:}}}
\renewcommand{\algorithmicensure} {\textbf{\textsc{Sorties:}}}
%\renewcommand{\algorithmicdo} {\textbf{do}}
\renewcommand{\algorithmicwhile}{\underline{do}}
\renewcommand{\algorithmicendwhile}{\underline{od}}
\renewcommand{\algorithmicend} {\underline{END.}}
\newcommand{\algorithmicbegin} {\underline{BEGIN}}
\renewcommand{\algorithmicif} {\underline{if}}
\renewcommand{\algorithmicendif} {\underline{fi}}
\renewcommand{\algorithmicelse} {\textbf{else}}
\renewcommand{\algorithmicthen} {\textbf{$\rightarrow$}}
\renewcommand{\algorithmicfor} {\textbf{pour}}
\renewcommand{\algorithmicforall} {\textbf{pour tout}}
\renewcommand{\algorithmicdo} {\textbf{$\rightarrow$}}
\renewcommand{\algorithmicendfor} {\textbf{fin pour}}
\renewcommand{\algorithmicloop} {\textbf{boucler}}
\renewcommand{\algorithmicendloop} {\textbf{fin boucle}}
\renewcommand{\algorithmicrepeat} {\textbf{répéter}}
\renewcommand{\algorithmicuntil} {\textbf{jusqu'à}}
\newcommand{\invariant} {\textbf{\{P\}}}%précondition
\renewcommand{\algorithmicrequire} {\textbf{\{I\}}}%précondition
\renewcommand{\algorithmicensure} {\textbf{\{R\}}}%postcondition
\renewcommand{\and}{\underline{and}}
\renewcommand{\or}{\underline{or}}
\renewcommand{\not}{\underline{not}}
\makeatletter
\newenvironment{breakalgo}[3][alg:\thealgorithm]{%
\def\@fs@cfont{\bfseries}%
\let\@fs@capt\relax%
\par\noindent%
\medskip%
%\rule{\linewidth}{.8pt}%
\vspace{-3pt}%
%\captionof{algorithm}{#2}\label{#1}%
%\vspace{-1.7\baselineskip}%
%\noindent\rule{\linewidth}{.4pt}%
%\vspace{-1.3\baselineskip}%
}{%
\vspace{-.75\baselineskip}%
\rule{\linewidth}{.4pt}%
\medskip%
}
[\code]
[\code]
Try my minimum working example:
[code]
\documentclass[10pt,a4paper,final,oneside]{article}
\usepackage[latin1]{inputenc}
\usepackage[french]{babel}
\usepackage{multicol} %permet d'utiliser le mode multicolonnes
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[usenames,dvipsnames]{pstricks}
\usepackage{epsfig}
%\usepackage{pst-grad} % For gradients
%\usepackage{pst-plot} % For axes
\usepackage{textcomp} % For degrees
\usepackage{pstricks}
\usepackage{pst-plot}
\usepackage{pst-text}
\usepackage{pst-tree}
\usepackage{pst-eps}
\usepackage{pst-fill}
\usepackage{pst-node}
\usepackage{pst-math}
\usepackage{pst-grad} % For gradients
\usepackage{gensymb}
\usepackage{fancyhdr}
\usepackage{algorithmic}
\usepackage{algorithm}
\usepackage{amsthm}
\usepackage{hyperref}
\addtolength{\voffset}{-2cm}
\addtolength{\textheight}{5cm}
\addtolength{\hoffset}{-3cm}
\addtolength{\textwidth}{5.2cm}
\providecommand{\abs}[1]{\lvert#1\rvert}
\providecommand{\norm}[1]{\lVert#1\rVert}
%%% francisation des algorithmes
\renewcommand{\algorithmicrequire} {\textbf{\textsc{Entrées:}}}
\renewcommand{\algorithmicensure} {\textbf{\textsc{Sorties:}}}
%\renewcommand{\algorithmicdo} {\textbf{do}}
\renewcommand{\algorithmicwhile}{\underline{do}}
\renewcommand{\algorithmicendwhile}{\underline{od}}
\renewcommand{\algorithmicend} {\underline{END.}}
\newcommand{\algorithmicbegin} {\underline{BEGIN}}
\renewcommand{\algorithmicif} {\underline{if}}
\renewcommand{\algorithmicendif} {\underline{fi}}
\renewcommand{\algorithmicelse} {\textbf{else}}
\renewcommand{\algorithmicthen} {\textbf{$\rightarrow$}}
\renewcommand{\algorithmicfor} {\textbf{pour}}
\renewcommand{\algorithmicforall} {\textbf{pour tout}}
\renewcommand{\algorithmicdo} {\textbf{$\rightarrow$}}
\renewcommand{\algorithmicendfor} {\textbf{fin pour}}
\renewcommand{\algorithmicloop} {\textbf{boucler}}
\renewcommand{\algorithmicendloop} {\textbf{fin boucle}}
\renewcommand{\algorithmicrepeat} {\textbf{répéter}}
\renewcommand{\algorithmicuntil} {\textbf{jusqu'à}}
\newcommand{\invariant} {\textbf{\{P\}}}%précondition
\renewcommand{\algorithmicrequire} {\textbf{\{I\}}}%précondition
\renewcommand{\algorithmicensure} {\textbf{\{R\}}}%postcondition
\renewcommand{\and}{\underline{and}}
\renewcommand{\or}{\underline{or}}
\renewcommand{\not}{\underline{not}}
\makeatletter
\newenvironment{breakalgo}[3][alg:\thealgorithm]{%
\def\@fs@cfont{\bfseries}%
\let\@fs@capt\relax%
\par\noindent%
\medskip%
%\rule{\linewidth}{.8pt}%
\vspace{-3pt}%
%\captionof{algorithm}{#2}\label{#1}%
%\vspace{-1.7\baselineskip}%
%\noindent\rule{\linewidth}{.4pt}%
%\vspace{-1.3\baselineskip}%
}{%
\vspace{-.75\baselineskip}%
\rule{\linewidth}{.4pt}%
\medskip%
}
\begin{document}
\section{Algorithme}
Après la déclaration, suivra immédiatement le programme, débuté par \verb BEGIN , et terminé par \verb END. .
\begin{breakalgo}
\begin{algorithm}
%\caption{Algorithme de la JT-Figure}
\begin{algorithmic}[1]
%%-----------------------------------------------
\STATE \{$P:((p\geq 0)\and (pmax\geq 0)\and (i\geq 0)\and (j\geq 0))$\}
\STATE BEGIN
\STATE $pmax:=0$;
\STATE $p:=1$;
\STATE $i,j:=0$;
\WHILE{$i<M$}
\IF{$j=N-1$}
\STATE $i:=i+1$;
\STATE $j:=0$
\ENDIF
\IF{not($j=(N-1)$)}
\IF{(\not($B[i,j]$))}
\STATE $p:=0$
\ENDIF
\WHILE{$orig=true$}
\IF{($B[i,j]$)}
\STATE $p:=p+1$;
\STATE $comp:=0$;
\STATE $k:=p-1$;
\WHILE{$(comp< (2k+1))$}
\WHILE{($B[i+k,comp]$) \and ($comp< (2k+1)$)}
\STATE $nb:=nb+1$;
\STATE $comp:=comp+1$
\ENDWHILE
\WHILE{(\not($B[i+k,comp]$))\and ($comp <(2k+1)$)}
\STATE $comp:=comp+1$
\ENDWHILE
\ENDWHILE
\STATE $comp:=2$;
\WHILE{$comp< (2k+1)$}
\WHILE{($B[i+k-1,comp]$)}
\STATE $nbdeux:=nbdeux+1$;
\STATE $comp:=comp+1$
\ENDWHILE
\WHILE{(\not($B[i+k-1,comp]$)\and ($comp<(2k+1)$))}
\STATE $comp:=comp+1$
\ENDWHILE
\IF{($nb>nbdeux$)}
\STATE $pmax:=pmax+1$;
\STATE $orig:=true$
\ENDIF
\IF{$nb\leq nbdeux$}
\STATE $orig:=false$
\ENDIF
\ENDWHILE
\ENDIF
\ENDWHILE
\ENDIF
\STATE $j:=j+1$
\ENDWHILE
\WHILE{($i<M$)}
\IF{($j=N-1$)}
\STATE $i:=i+1$;
\STATE $j:=0$
\ENDIF
\IF{\not($j=N-1$)}
\IF{\not($B[i,j]$)}
\STATE $p:=0$
\ENDIF
\IF{$B[i,j]$}
\STATE $l:=0$;
\WHILE{($l< pmax$)}
\STATE $m:=i$;
\STATE $n:=j$;
\WHILE{($m<M$)}
\IF{($n=N-1$)}
\STATE $m:=m+1$;
\STATE $n:=0$;
\STATE $l:=l+1$
\ENDIF
\STATE $n:=n+1$;
\STATE $l:=l+1$
\ENDWHILE
\ENDWHILE
\ENDIF
\STATE $nbel:=nbel+1$;
\IF{$pmax>1$}
\STATE $new(lst)$;
\STATE $lst\uparrow .info:=m$;
\STATE $lst\uparrow .next:=n$;
\STATE $n:=m$;
\ENDIF
\ENDIF
\STATE $j:=j+1$
\ENDWHILE
\IF{$pmax\leq 1$}
\STATE $m:=0$;
\STATE $n:=0$;
\STATE $new(lst)$;
\STATE $lst\uparrow .info:=m$;
\STATE $lst\uparrow .next:=n$;
\ENDIF
\STATE END.
\end{algorithmic}
\end{algorithm}
\end{breakalgo}
\newpage
\section{Schéma de la figure à détecter}
Comme il n'est pas détaillé ce qu'est une JT-figure d'une dimension (finie) donnée dans l'énoncé, on ne peut que
donner un exemple de schéma de JT-figure à détecter. De plus, on déduit de l'énoncé qu'une JT-figure est formée de
deux extrémités, toutes les deux étant de type ``true''. Les éléments entre ces deux origines sont quelconques, bien
que booléens.
% Generated with LaTeXDraw 2.0.1
% Sun Nov 30 18:31:29 CET 2008
% \usepackage[usenames,dvipsnames]{pstricks}
% \usepackage{epsfig}
% \usepackage{pst-grad} % For gradients
% \usepackage{pst-plot} % For axes
\begin{center}
\begin{figure}[h]
\begin{pspicture}(0,-1.9310937)(5.3,1.9510938)
\psline[linewidth=0.04cm](0.82,1.4089062)(0.82,-1.9110937)
\psline[linewidth=0.04cm](0.02,0.46890625)(5.28,0.48890626)
\psline[linewidth=0.04cm](0.0,-1.2110938)(5.26,-1.1910938)
\psline[linewidth=0.04cm](4.44,1.4089062)(4.44,-1.9110937)
\usefont{T1}{ptm}{m}{n}
\rput(4.8098435,0.79890627){N}
\usefont{T1}{ptm}{m}{n}
\rput(0.5132812,-1.4810938){M}
\usefont{T1}{ptm}{m}{n}
\rput(1.0370313,0.23890625){0}
\usefont{T1}{ptm}{m}{n}
\rput(1.386875,0.21890625){1}
\usefont{T1}{ptm}{m}{n}
\rput(1.7970313,0.21890625){0}
\usefont{T1}{ptm}{m}{n}
\rput(2.2370312,0.21890625){0}
\usefont{T1}{ptm}{m}{n}
\rput(2.606875,0.23890625){1}
\usefont{T1}{ptm}{m}{n}
\rput(3.006875,0.23890625){1}
\usefont{T1}{ptm}{m}{n}
\rput(3.3970313,0.23890625){0}
\usefont{T1}{ptm}{m}{n}
\rput(3.7770312,0.23890625){0}
\usefont{T1}{ptm}{m}{n}
\rput(4.157031,0.21890625){0}
\usefont{T1}{ptm}{m}{n}
\rput(1.006875,-0.24109375){1}
\usefont{T1}{ptm}{m}{n}
\rput(1.4170313,-0.26109374){0}
\usefont{T1}{ptm}{m}{n}
\rput(1.766875,-0.26109374){1}
\usefont{T1}{ptm}{m}{n}
\rput(0.986875,-0.74109375){1}
\usefont{T1}{ptm}{m}{n}
\rput(1.3970313,-0.7210938){0}
\usefont{T1}{ptm}{m}{n}
\rput(1.7770313,-0.74109375){0}
\usefont{T1}{ptm}{m}{n}
\rput(2.2170312,-0.7210938){0}
\usefont{T1}{ptm}{m}{n}
\rput(2.6770313,-0.7210938){0}
\usefont{T1}{ptm}{m}{n}
\rput(3.0770311,-0.74109375){0}
\usefont{T1}{ptm}{m}{n}
\rput(3.4370313,-0.7210938){0}
\usefont{T1}{ptm}{m}{n}
\rput(3.7970312,-0.7210938){0}
\usefont{T1}{ptm}{m}{n}
\rput(4.177031,-0.74109375){0}
\usefont{T1}{ptm}{m}{n}
\rput(2.2170312,-0.26109374){0}
\usefont{T1}{ptm}{m}{n}
\rput(2.6770313,-0.26109374){0}
\usefont{T1}{ptm}{m}{n}
\rput(3.0770311,-0.28109375){0}
\usefont{T1}{ptm}{m}{n}
\rput(3.4370313,-0.26109374){0}
\usefont{T1}{ptm}{m}{n}
\rput(3.7970312,-0.26109374){0}
\usefont{T1}{ptm}{m}{n}
\rput(4.177031,-0.28109375){0}
\psline[linewidth=0.04cm,arrowsize=0.05291667cm
2.0,arrowlength=1.4,arrowinset=0.4]{->}(2.98,0.28890625)(2.88,1.5089062)
\usefont{T1}{ptm}{m}{n}
\rput(2.7678125,1.7839062){\footnotesize Origine d'une JT-figure($p$)|$p=2$}
\end{pspicture}
\end{figure}
\caption{Test.}
\end{center}
\end{document}