From: carlos@cs.man.ac.uk (Carlos Camarao de Figueiredo)
Newsgroups: soc.culture.brazil
Subject: Re: Usar acentos em TeX/LaTex
Date: 30 Aug 92 15:18:27 GMT
Organization: Department of Computer Science, University of Manchester, U.K.
In-reply-to: cgwillme@cybaswan.UUCP's message of 27 Aug 92 23:31:08 GMT


A'i vai "accent.p" que traduz: 
      ,c        para            \c{c}
      `a        para            \`a 

etc., exceto quando dentro de "verbatim", "verb" etc.

Acredito que ajude. 

===================accent.p==============================
  PROGRAM ACCENT(input, output);

  (*
   * ACCENT is a software filter that helps LaTeX users to prepare documents
   * written in portuguese. Its main task is to ease the use of words with
   * accents. The user produces a ".lat" file with accents inserted in the
   * way that they are normally typed on an ordinary typewriter. The ".lat"
   * file is the input to ACCENT which produces a corresponding ".tex" file
   * to be submitted to LaTeX.
   *
   * ACCENT also substitutes tabs by the appropriate number of spaces.
   * ACCENT does not change text inside a verbatim environment.
   *
   *)

  CONST
    comma        = ',';
    doublequote  = '"';
    circunflex   = '^';
    quote        = '''';
    crasis       = '`';
    tilde        = '~';
    backslash    = '\';
    space        = ' ';
    tablen       = 8;
    maxlineleng  = 1000;

  TYPE
    verbatim_kind = (no, begin_verbatim, begin_verbatim_star, verb, verb_star);

  VAR
    verb_delim,
    tab,
    ch,
    nextch:       char;
    accents,
    specialchars,
    vowelletters: SET OF char;
    verbatim:     verbatim_kind;
    charpos,
    charcnt:      integer;
    linbuf:       PACKED ARRAY [1..maxlineleng] OF char;


  FUNCTION Checktab : boolean;
    VAR
      i: integer;
    BEGIN
      IF ch = tab THEN
        BEGIN
	  FOR i := 1 TO tablen - ((charpos - 1) MOD tablen) DO
            Write(space);
	  charpos := charpos + tablen - (charpos MOD tablen);
          Checktab := TRUE
	END
      ELSE
        Checktab := FALSE
    END {Checktab};


  FUNCTION BeginVerbatim : verbatim_kind;
    BEGIN
      BeginVerbatim := no;
      IF (charcnt - charpos >= 15) (*Size-1 of "\begin{verbatim}"*) THEN
        BEGIN
          IF (linbuf[charpos]='\')    AND (linbuf[charpos+1]='b')  AND
             (linbuf[charpos+2]='e')  AND (linbuf[charpos+3]='g')  AND
             (linbuf[charpos+4]='i')  AND (linbuf[charpos+5]='n')  AND
             (linbuf[charpos+6]='{')  AND (linbuf[charpos+7]='v')  AND
             (linbuf[charpos+8]='e')  AND (linbuf[charpos+9]='r')  AND
             (linbuf[charpos+10]='b') AND (linbuf[charpos+11]='a') AND
             (linbuf[charpos+12]='t') AND (linbuf[charpos+13]='i') AND
             (linbuf[charpos+14]='m') THEN
            IF linbuf[charpos+15]='}' THEN
              BEGIN
                BeginVerbatim := begin_verbatim;
                Write('\begin{verbatim}');
                charpos := charpos + 16
              END
            ELSE
              IF (charcnt - charpos >= 16) AND (linbuf[charpos+15]='*') AND
                 (linbuf[charpos+16]='}') THEN
                BEGIN
                  BeginVerbatim := begin_verbatim_star;
                  Write('\begin{verbatim*}');
                  charpos := charpos + 17
                END
        END
      ELSE
        IF (charcnt - charpos >= 5) (*Size-1 of "\verbx"*) THEN
          IF (linbuf[charpos]='\')   AND (linbuf[charpos+1]='v')  AND
             (linbuf[charpos+2]='e') AND (linbuf[charpos+3]='r')  AND
             (linbuf[charpos+4]='b') THEN
            IF (charcnt - charpos >= 6) (*Size-1 of "\verb*x"*) AND
               (linbuf[charpos+5]='*') THEN
              BEGIN
                BeginVerbatim := verb_star;
                verb_delim := linbuf[charpos+6];
                Write('\verb*',verb_delim);
                charpos := charpos + 7
              END
            ELSE
              BEGIN
                BeginVerbatim := verb;
                verb_delim := linbuf[charpos+5];
                Write('\verb',verb_delim);
                charpos := charpos + 6
              END
    END {BeginVerbatim};
  
  FUNCTION EndVerbatim : boolean;
    BEGIN
      EndVerbatim := FALSE;
      IF (verbatim = begin_verbatim) OR 
         (verbatim = begin_verbatim_star) THEN
        BEGIN
          IF (charcnt-charpos >= 13) (*Size-1 of "\end{verbatim}" *) THEN
            IF (linbuf[charpos]='\')    AND (linbuf[charpos+1]='e')  AND
               (linbuf[charpos+2]='n')  AND (linbuf[charpos+3]='d')  AND
               (linbuf[charpos+4]='{')  AND (linbuf[charpos+5]='v')  AND
               (linbuf[charpos+6]='e')  AND (linbuf[charpos+7]='r')  AND
               (linbuf[charpos+8]='b')  AND (linbuf[charpos+9]='a')  AND
               (linbuf[charpos+10]='t') AND (linbuf[charpos+11]='i') AND
               (linbuf[charpos+12]='m') AND (linbuf[charpos+13]='}') THEN
              EndVerbatim := TRUE
        END
      ELSE
        IF (verbatim = verb) OR (verbatim = verb_star) THEN
          IF linbuf[charpos]=verb_delim THEN
            EndVerbatim := TRUE
    END {EndVerbatim};

  PROCEDURE Next;
    BEGIN
      IF Checktab THEN
        {Nothing}
      ELSE
        BEGIN
          Write(linbuf[charpos]);
          charpos := charpos + 1
        END
    END {Next};

  BEGIN {ACCENT}
    tab := Chr(9);

    accents := [crasis, quote, circunflex, tilde];

    specialchars := accents + [comma, doublequote, 'a', 'A'];

    vowelletters := ['a', 'e', 'i', 'o', 'u',
                     'A', 'E', 'I', 'O', 'U'];

    verbatim := no;
    WHILE NOT Eof(input) DO
      BEGIN
	charcnt := 0;
	WHILE NOT Eoln(input) DO
          BEGIN
            charcnt := charcnt + 1;
            Read(linbuf[charcnt])
          END;
        charpos := 1;
        WHILE charpos <= charcnt DO 
          BEGIN
            IF verbatim = no THEN 
              verbatim := BeginVerbatim;
            IF (verbatim = no) AND (linbuf[charpos] IN specialchars) AND 
               (charcnt - charpos >= 1) THEN
              BEGIN
                ch := linbuf[charpos];
	        charpos := charpos + 1;
                nextch := linbuf[charpos];
  	        IF ch = comma THEN
                  IF nextch = comma THEN
                    Write(comma)
                  ELSE
                    IF (nextch = 'c') OR (nextch = 'C') THEN
		      Write(backslash, 'c{', nextch, '}')
                    ELSE
                      BEGIN
                        Write(comma);
                        charpos := charpos - 1 
                      END
                ELSE
                  IF (ch = 'a') OR (ch = 'A') THEN
                    IF ch = nextch THEN
                      Write(backslash, crasis, ch)
                    ELSE
                      BEGIN
                        Write(ch);
                        charpos := charpos - 1
                      END
		  ELSE
		    IF (ch = crasis) AND (nextch = crasis) THEN
		      Write(crasis, crasis)
		    ELSE
		      IF nextch IN vowelletters THEN
		        BEGIN
			  Write(backslash, ch);
			  IF nextch = 'i'
         		    THEN Write('{\i}')
			    ELSE Write(nextch)
			END
		      ELSE
                        BEGIN
			  Write(ch);
                          charpos := charpos - 1
			END;
                  charpos := charpos + 1
                END
	      ELSE
                IF (verbatim <> no) AND EndVerbatim THEN
                  BEGIN 
                    IF (verbatim = begin_verbatim) OR 
                       (verbatim = begin_verbatim_star) THEN
                      BEGIN
                        Write('\end{verbatim}');
                        charpos := charpos + 14
                      END
                    ELSE
                      BEGIN
                        Write(verb_delim);
                        charpos := charpos + 1
                      END;
                    verbatim := no
                  END
                ELSE
                  Next
	  END {WHILE charpos <= charcnt};
        Readln;
        Writeln
      END {WHILE NOT Eof(input};

  END {ACCENT}.
===================fim accent.p==========================

--
+-----------------------------------------------------------------+
|   Carlos Camar~ao de Figueiredo                                 |
|                                       Univ. Manchester          |
|   Tel: +44 61 275 6148                Dept. Comp. Science       |
|   Fax: +44 61 275 6236                Oxford Rd., M13 9PL       |
|   E-mail: carlos@cs.man.ac.uk         Manchester UK             |
+_________________________________________________________________+
Newsgroups: soc.culture.brazil