Re: Pacchetto Macchine di Turing Vs Hyperref

#64336
Up
0
Down
::

Dork” post=63393Grazie mille, è incredibile ora funziona grazie infinite!
Sei per caso riuscito a vedere anche il problema con il listings? Ho provato a eseguire il tup .sty e non da né warning ne altro l’unica cosa mi dava erano una marea di bad hbox ma con
`\begin{lstlisting}[basicstyle=\footnotesize,firstnumber=0,frame=trBL,linewidth=\linewidth,caption={MdT somma},label{MdT:som}]
&!\showtm
\runtm!&
\end{lstlisting}`

ho risolto. Il problema della prima riga, che è totalmente in più (io l’ho numerata con zero così la prima della MdT è 1) però resta: lei è in più e tutte le altre sotto di lei sono sfasate verso destra uscendo dai margini (con basicstyle=\footnotesize,linewidth=\linewidth evito i bad box ma lo sfasamento e la cornice tutta rotta, nel senso che ogni riga ha il suo pezzettino a margine di cornice, restano)

Versione riveduta e corretta:
`%=============================================================================
% Turing — (turing.sty) Style file
% A LaTeX class for defining and using Turing machines.
% Author: Mark Schaefer (mark.schaefer@informatik.uni-augsburg.de)
% University of Augsburg, Germany
%
% Copyright (c) 2006 Mark Schaefer
% All rights reserved.
%
% Permission is hereby granted, without written agreement and without
% license or royalty fees, to use, copy, modify, and distribute this
% software and its documentation for any purpose, provided that the
% above copyright notice and the following two paragraphs appear in
% all copies of this software.
%
% IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
% SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
% THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHOR HAS BEEN ADVISED
% OF THE POSSIBILITY OF SUCH DAMAGE.
%
% THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES,
% INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
% AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
% ON AN “AS IS” BASIS, AND THE AUTHOR HAS NO OBLIGATION TO
% PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
%
%==============================================================================
% This package allows the definition, simulation and graphical display of
% deterministic Turing machines. For the time being this manual assumes that
% the reader is familiar with this concept.
%
% One can initialise a new Turing machine by \newtm(band content).
% The band entries have to be separated by a ',', after the rightmost entry,
% no ',' is allowed. start and stop denote states of the Turing machine
% (obviously, THE start and THE stop state). In general states and band entries
% can be arbitrary strings, where '-' is used as blank, special characters have
% to be escaped, e.g. as \# Don't use '=' for states or entries.
%
% For example: \newtm(-,1,0,1,0,\#,1,0,1,-)
%
% The next-state function is defined by \turingrules{rule1,rule2,…,ruleN}, as
% for the band entries, rules are separated by ',' and again after the last
% rule, no ',' is allowed. % Rules have the form
% (old_state, current_entry, new_state, new_entry, (L|H|R)}.
%
% For example: \turingrules{(q0,0,q0,1,R),(q0,1,q0,0,R),(q0,-,stop,-,H)}
%
% Note that the next-state function does not have to be complete; an error
% message is generated if an entry is not found while the old state of the
% Turing machine is preserved.
%
% A graphical representation is generated by \showtm, the following state is
% generated by \nextstep. Once, the stop-state is reached, \nextstep will have
% no effect.
%
% For convenience, there are the following three commands:
%
% – \stepandshow : makes a step and shows the next state, this is repeated times,
% e.g. \stepandshow{100}
% – \loopstep
: same as \stepandshow, but the intermediate results are not printed
%
% – \runtm : same as \stepandshow, but the Turing machine stops automatically, if
% the stop state was reached
% Caution! The Turing machine may run forever, and so will latex.
%
% Have a look at the output of TeX, error messages will be reported there.
%==============================================================================

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{turing}[2006/02/17]
\message{This is Turing-Tex.}

\def\tm@newworld{=}
\def\tm@blank{-}

\def\newtm<#1,#2>(#3){%
\xdef\tm@tm{(=,)(#1)(#3,=,)}%
\xdef\tm@stopstate{#2}%
\xdef\tm@stopreached{no}%
}

\def\turingrules#1{%
\xdef\tm@rules{#1,(,,,,),}%
}

\def\tm@findstate(#1,#2)(#3)(#4,#5,#6);{%
\xdef\tm@farleft{#2}%
\xdef\tm@left{#1}%
\xdef\tm@state{#3}%
\xdef\tm@value{#4}%
\xdef\tm@right{#5}%
\xdef\tm@farright{#6}%
}

\newif\iftm@norulegiven
\newif\iftm@norulefound

\def\tm@findrule{%
\tm@norulegivenfalse
\tm@norulefoundtrue
\xdef\tm@remrules{\tm@rules}%
\loop
\expandafter\tm@findr\tm@remrules;%
\iftm@norulefound
\repeat
}

\def\tm@findr(#1,#2,#3,#4,#5),#6;{%
\edef\tm@stpe{#1}%
\edef\tm@stpv{#2}%
\ifx\tm@state\tm@stpe
\ifx\tm@value\tm@stpv
\tm@norulefoundfalse
\xdef\tm@newstate{#3}%
\xdef\tm@newvalue{#4}%
\xdef\tm@direction{#5}%
\fi
\fi
\xdef\tm@remrules{#6}%
\ifx\@empty\tm@remrules
\tm@norulefoundfalse
\tm@norulegiventrue
\fi
}

\def\tm@nextstep{%
\expandafter\tm@findstate\tm@tm;%
\tm@findrule
\ifx\tm@newstate\tm@stopstate\xdef\tm@stopreached{yes}\fi
\iftm@norulegiven
\ifx\tm@state\tm@stopstate
\message{Turing machine reached stop state.}%
\else
\message{Rule not found for (state,value) (\tm@state,\tm@value)}%
\fi
\else
\def\tm@leftm{L}%
\def\tm@rightm{R}%
\def\tm@middlem{H}%
\if\tm@direction\tm@leftm
\if\tm@left\tm@newworld
\xdef\tm@tm{(=,\tm@farleft)(\tm@newstate)(-,\tm@newvalue,\tm@right,\tm@farright)}%
\else
\xdef\tm@tm{(\tm@farleft)(\tm@newstate)(\tm@left,\tm@newvalue,\tm@right,\tm@farright)}%
\fi
\else\if\tm@direction\tm@rightm
\if\tm@right\tm@newworld
\xdef\tm@tm{(\tm@newvalue,\tm@left,\tm@farleft)(\tm@newstate)(-,=,\tm@farright)}%
\else
\xdef\tm@tm{(\tm@newvalue,\tm@left,\tm@farleft)(\tm@newstate)(\tm@right,\tm@farright)}%
\fi
\else\if\tm@direction\tm@middlem
\xdef\tm@tm{(\tm@left,\tm@farleft)(\tm@newstate)(\tm@newvalue,\tm@right,\tm@farright)}%
\fi\fi\fi
\fi
}

\def\tm@spec#1{\vbox{
\hbox to 1em {\vrule height0.1em depth0.2em\hss#1\hss\vrule height0.1em}\hrule}}
\def\tm@speca#1{\vbox{\hrule
\hbox to 1em {\vrule height0.8em depth0.2em\hss#1\hss\vrule height0.8em}\hrule}}

\newif\iftm@tmfull
\newif\iftm@nextvalue

\def\showtm{%
\xdef\tm@result{}%
\expandafter\tm@findstate\tm@tm;%
\tm@tmfulltrue
\edef\tm@remtm{\tm@left,\tm@farleft}%
\loop
\expandafter\tm@mkleft\tm@remtm;
\iftm@tmfull
\repeat
\if\tm@value\tm@blank
\xdef\tm@result{\tm@result\tm@speca{}\ }%
\else
\xdef\tm@result{\tm@result\tm@speca{\tm@value}\ }%
\fi
\tm@tmfulltrue
\edef\tm@remtm{\tm@right,\tm@farright}%
\loop
\expandafter\tm@mkright\tm@remtm;%
\iftm@tmfull
\repeat
\mbox{}\tm@result\hskip3em(\tm@state)\par
}

\def\tm@mkleft#1,#2;{%
\edef\tm@next{#1}%
\if\tm@next\tm@newworld
\xdef\tm@result{\tm@spec{}\ \tm@result}%
\else\if\tm@next\tm@blank
\xdef\tm@result{\tm@result\tm@spec{}\ }%
\else
\xdef\tm@result{\tm@spec{#1}\ \tm@result}%
\fi\fi
\edef\tm@remtm{#2}%
\ifx\@empty\tm@remtm
\tm@tmfullfalse
\fi
}

\def\tm@mkright#1,#2;{%
\edef\tm@next{#1}%
\if\tm@next\tm@newworld
\xdef\tm@result{\tm@result\tm@spec{}\ }%
\else\if\tm@next\tm@blank
\xdef\tm@result{\tm@result\tm@spec{}\ }%
\else
\xdef\tm@result{\tm@result\tm@spec{#1}\ }%
\fi\fi
\edef\tm@remtm{#2}%
\ifx\@empty\tm@remtm
\tm@tmfullfalse
\fi
}

\newcount\tm@tmit
\def\stepandshow#1{%
\tm@tmit=#1
\loop
{\tm@nextstep\showtm}%
\advance\tm@tmit by -1
\ifnum\tm@tmit>0
\repeat
}

\long\def\runtm{%
\loop
{\tm@nextstep\showtm}%
\def\tm@next{no}%
\ifx\tm@next\tm@stopreached
\repeat
}

\def\loopstep#1{%
\tm@tmit=#1
\loop
{\tm@nextstep}
\advance\tm@tmit by -1
\ifnum\tm@tmit>0
\repeat
}

\endinput`
Adesso la riga in più non c’è. Il problema è la cornice tratteggiata dovuta al fatto che le righe sono troppo profonde:
`\begin{lstlisting}[basicstyle=\linespread{1.4}\footnotesize\ttfamily,%firstnumber=0,
frame=trBL,linewidth=\linewidth,caption={MdT somma},label={MdT:som}]`
Ciao
Enrico

Go to top