- Questo topic ha 10 risposte, 3 partecipanti ed è stato aggiornato l'ultima volta 14 anni, 11 mesi fa da .
-
Topic
-
Ciao a tutti, avevo bisogno di scrivere delle macchine di Turing a nastro e ho cercato un po’ trovando il pacchetto che allego. Tutto ok facendo partire il suo esempio ma nel mio codice non funziona. Provo a fare emc e scopro che il problema è l’hyperref. Ora…io di pacchetti non so nulla né di hyperref 🙂 qualcuno potrebbe aiutarmi e dirmi come poter sistemare le cose?
ps commentato nel codice c’è il geometry originale del pacchetto ma io ho lasciato il layaureo perché uso quello.
Ho lasciato tutte le ipostazioni di formattazione perché credo potrebbero essere importanti.
A riguardo del listings c’è invece un’altro problema e cioé, anche togliendo l’hyperref, e quindi facendo in modo che il pacchetto turing funzioni correttamente, mi stampa tutto ok più una riga di codice vuota e sfasata all’inizio che non riesco a togliere (e mi impedisce di fare i riquadri che verrebbero orribili), questo è un problema secondario perché ho risolto facendo partire la numerazione da zero, togliendo il riquadro e bon il risultato è almeno accettabile..se però oltre a scoprire come fare per poterlo usare (con hyperref) qualcuno riesce anche a togliere quella righina fastidiosa…super!!
p.s la mdt riportata è quella dell’esempio del pacchetto originale e genera circa 3 pagine, inoltre segnalo che l’originale usa l’article ma io uso il report (però senza hyperref funziona comunque bene lostesso).
Grazie a tutti e spero che questo pacchetto possa anche essere utile a qualcun’altro!…cavolo visto che non arrivo ad allegare il file .sty (qualcuno sa perhè mi dice non trovato sia che faccia aggiungi file sia che lo trascini dentro la finestra?!) lo riporto come codice completo quì sotto!!
`\documentclass[12pt,
a4paper,twoside,openright, %openright per capitoli sempre a dx;
notitlepage,
fleqn ,
]{report}\usepackage[T1]{fontenc}
\usepackage[applemac]{inputenc}
\usepackage[english,italian]{babel}\usepackage[binding=5mm]{layaureo}
%\usepackage[colorlinks,hyperindex,linkcolor=black,citecolor=black,bookmarks=false,hyperfootnotes=true]{hyperref}
%\hypersetup{
% pdftitle={Emc MdT},
% pdfauthor={Memmedesimo},
% pdfsubject={Problemi hyperref-VS-pacchettoMdT}
% pdfkeywords={problemi, MdT, Hyperreff}}\usepackage{listings}
\lstset{numbers=left,,basicstyle=\small\ttfamily,frameround=fttt,escapeinside={&!}{!&}}\usepackage{turing}
%\usepackage{geometry}
%\geometry{textwidth=170mm,textheight=250mm}\begin{document}
\newtm
(1,0,1,1,0,1,0,1,\#,1,0,1,1,0,1)
\turingrules{%
(next,0,next,0,R),%
(next,1,next,1,R),%
(next,0',next,0',R),%
(next,1',next,1',R),%
(next,\#,next,\#,R),%
(next,-,check,-,L),%
%
(check,0,prepadd0,-,L),%
(check,1,prepadd1,-,L),%
(check,\#,cleanup,-,L),%
%
(prepadd0,0,prepadd0,0,L),%
(prepadd0,1,prepadd0,1,L),%
(prepadd0,\#,add0,\#,L),%
(add0,0',add0,0',L),%
(add0,1',add0,1',L),%
(add0,-,next,0',R),%
(add0,0,next,0',R),%
(add0,1,next,1',R),%
%
(prepadd1,0,prepadd1,0,L),%
(prepadd1,1,prepadd1,1,L),%
(prepadd1,\#,add1,\#,L),%
(add1,0',add1,0',L),%
(add1,1',add1,1',L),%
(add1,0,next,1',R),%
(add1,1,propadd1,0',L),%
(add1,-,next,1',R),%
(propadd1,0,next,1,R),%
(propadd1,1,propadd1,0,L),%
(propadd1,-,next,1,R),%
%
(cleanup,0,cleanup,0,L),%
(cleanup,1,cleanup,1,L),%
(cleanup,0',cleanup,0,L),%
(cleanup,1',cleanup,1,L),%
(cleanup,-,stop,-,H)%
}
\begin{lstlisting}[firstnumber=0,caption=ciccio]
&!
\showtm
\runtm
!&
\end{lstlisting}
\end{document}``%=============================================================================
% 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\newworld{=}
\def\blank{-}\def\newtm<#1,#2>(#3){
\xdef\tm{(=,)(#1)(#3,=,)}
\xdef\stopstate{#2}
\xdef\stopreached{no}
}\def\turingrules#1{
\xdef\rules{#1,(,,,,),}
}\def\findstate(#1,#2)(#3)(#4,#5,#6);{
\xdef\farleft{#2}
\xdef\left{#1}
\xdef\state{#3}
\xdef\value{#4}
\xdef\right{#5}
\xdef\farright{#6}
}\newif\ifnorulegiven
\newif\ifnorulefound\def\findrule{
\norulegivenfalse
\norulefoundtrue
\xdef\remrules{\rules}
\loop
\expandafter\findr\remrules;
\ifnorulefound
\repeat
}\def\findr(#1,#2,#3,#4,#5),#6;{
\edef\stpe{#1}
\edef\stpv{#2}
\ifx\state\stpe
\ifx\value\stpv
\norulefoundfalse
\xdef\newstate{#3}
\xdef\newvalue{#4}
\xdef\direction{#5}
\fi
\fi\xdef\remrules{#6}
\ifx\empty\remrules
\norulefoundfalse
\norulegiventrue
\fi
}\def\nextstep{
\expandafter\findstate\tm;
\findrule\ifx\newstate\stopstate\xdef\stopreached{yes}\fi
\ifnorulegiven
\ifx\state\stopstate
\message{Turing machine reached stop state.}
\else
\message{Rule not found for (state,value) (\state,\value)}
\fi
\else
\def\leftm{L}
\def\rightm{R}
\def\middlem{H}\if\direction\leftm
\if\left\newworld
\xdef\tm{(=,\farleft)(\newstate)(-,\newvalue,\right,\farright)}
\else
\xdef\tm{(\farleft)(\newstate)(\left,\newvalue,\right,\farright)}
\fi
\else\if\direction\rightm
\if\right\newworld
\xdef\tm{(\newvalue,\left,\farleft)(\newstate)(-,=,\farright)}
\else
\xdef\tm{(\newvalue,\left,\farleft)(\newstate)(\right,\farright)}
\fi
\else\if\direction\middlem
\xdef\tm{(\left,\farleft)(\newstate)(\newvalue,\right,\farright)}
\fi\fi\fi\fi
}\def\spec#1{\vbox{\hbox to 1em {\vrule height0.1em depth0.2em\hfill#1\hfill{}\vrule height0.1em}\hrule}}
\def\speca#1{\vbox{\hrule\hbox to 1em {\vrule height0.8em depth0.2em\hfill#1\hfill{}\vrule height0.8em}\hrule}}\newif\iftmfull
\newif\ifnextvalue\def\showtm{
\xdef\result{}\expandafter\findstate\tm;
\tmfulltrue
\edef\remtm{\left,\farleft}
\loop
\expandafter\mkleft\remtm;
\iftmfull
\repeat\if\value\blank
\xdef\result{\result\speca{}\ }
\else
\xdef\result{\result\speca{\value}\ }
\fi\tmfulltrue
\edef\remtm{\right,\farright}
\loop
\expandafter\mkright\remtm;
\iftmfull
\repeat\mbox{}\result\hskip3em(\state)
}\def\mkleft#1,#2;{
\edef\next{#1}
\if\next\newworld
\xdef\result{\spec{}\ \result}
\else\if\next\blank
\xdef\result{\result\spec{}\ }
\else
\xdef\result{\spec{#1}\ \result}
\fi\fi
\edef\remtm{#2}
\ifx\empty\remtm
\tmfullfalse
\fi
}\def\mkright#1,#2;{
\edef\next{#1}
\if\next\newworld
\xdef\result{\result\spec{}\ }
\else\if\next\blank
\xdef\result{\result\spec{}\ }
\else
\xdef\result{\result\spec{#1}\ }
\fi\fi
\edef\remtm{#2}
\ifx\empty\remtm
\tmfullfalse
\fi
}\def\stepandshow#1{%
\newcount\tmit
\tmit=#1
\loop
{\nextstep\showtm}
\advance\tmit by -1
\ifnum\tmit>0
\repeat
}\def\runtm{%
\loop
{\nextstep\showtm}
\def\next{no}
\ifx\next\stopreached
\repeat
}\def\loopstep#1{%
\newcount\tmit
\tmit=#1
\loop
{\nextstep}
\advance\tmit by -1
\ifnum\tmit>0
\repeat
}\endinput`
- Devi essere connesso per rispondere a questo topic.