Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: \verb ended by end of line.

480 views
Skip to first unread message
Message has been deleted

Enrico Gregorio

unread,
Mar 30, 2008, 4:28:30 PM3/30/08
to
<jeanpier...@gmail.com> wrote:

> Bonjour,
>
> J'aimerais définir une nouvelle commande prenant en paramètre un
> argument qui sera une fois affiché sans interprétation de latex (en
> verbatim) et une nouvelle foit affiché normalement (c'est à dire
> interprété normalement par latex).

Please, note that this is an English speaking group.

> J'ai donc définit cette nouvelle commande de cette manière:
>
> \documentclass{article}
> \usepackage[latin1]{inputenc} % codage des caractères et coupures
> cyrilliques
> \usepackage{verbatim}
> \usepackage{listings}
> \usepackage{alltt}
>
> \newcommand\nomDeMaCommande[1]{\verb|#1| #1}

You can't use \verb in the argument of any command. Look at
the listings package to get what you want.

Ciao
Enrico

Ulrich Diez

unread,
Mar 30, 2008, 4:55:06 PM3/30/08
to
jeanpier...@gmail.com a écrit:

[...]


> \newcommand\nomDeMaCommande[1]{\verb|#1| #1}

[...]
> Pouvez-vous me dire pourquoi cela ne marche pas ?

(Il y a longtemps depuis que j'ai du apprendre quelques
mots de la langue française...)

"\verb" interprete son argument littéralement par _lire
l'argument du fichier-input_ après changer les catcodes des
quelques caractères.

L'argument de la macro "\nomDeMaCommande" est passé
à la macro "\verb".

En conséquence l'argument de la macro "\verb" est lu par
la macro "\nomDeMaCommande".

Mais pendant que "\nomDeMaCommande" lit son argument,
il n'y a pas des changes des catcodes...

> et comment
> solutionner mon problème
[...]

En plagiant le macro "\verb" (\verb -> \nomDeMaCommande,
\@verb -> \@nomDeMaCommande, \@sverb -> \@snomDeMaCommande),
on pourrait se servir de la primitive "\scantokens" (e-TeX!)
pour transformer l'argument "verbatim" en un argument
"normalement".

Ulrich


\documentclass{article}
\usepackage[latin1]{inputenc} % codage des caractères et coupures cyrilliques
\usepackage{verbatim}
\usepackage{listings}
\usepackage{alltt}

\makeatletter

\newcommand*\nomDeMaCommande{%
\relax
\ifmmode\hbox\else\leavevmode\null\fi
\bgroup
\verb@eol@error
\let\do\@makeother\dospecials
\verbatim@font\@noligs
\@ifstar\@snomDeMaCommande\@nomDeMaCommande
}%
\newcommand*\@nomDeMaCommande{\@vobeyspaces\frenchspacing\@snomDeMaCommande}%
\newcommand*\@snomDeMaCommande[1]{%
\catcode`#1\active
\lccode`\~`#1%
\gdef\verb@balance@group{%
\verb@egroup\@latex@error{%
\noexpand\verb illegal in command argument%
}\@ehc
}%
\aftergroup\verb@balance@group
\lowercase{%
\let ~\verb@egroup
\def\@tempa##1~{##1~ \scantokens{##1}}%
}%
\@tempa
}%
\makeatother

\begin{document}

\nomDeMaCommande|\emph{toto} titi @ ` $x^2_c\sum$|

\nomDeMaCommande*|\emph{toto} titi @ ` $x^2_c\sum$|

\end{document}

jeanpier...@gmail.com

unread,
Mar 31, 2008, 6:40:24 AM3/31/08
to
Thank both of you for your answers!
Special thank to Ulrich for his French answer!
Sorry, I have sent my message at wrong groups (comp.text.tex instead
of fr.comp.text.tex). That's the reason why I have deleted my
message... too late!

I think you have understood, but just for information I try to
translate in English....

I would like define a new command with one parameter which will be
display in verbatim mode and one more time in classic mode. But I have
some problem with my new definition:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\documentclass{article}
\usepackage[latin1]{inputenc}

\usepackage{verbatim}
\usepackage{listings}
\usepackage{alltt}

\newcommand\nameOfMyCommand[1]{\verb|#1| #1}

\begin{document}

\nameOfMyCommand{\emph{hello} hello @ ` $x^2_c\sum$}

\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--------------------------------------------------------------------------------------------------

Error message:

--------------------------------------------------------------------------------------------------
\verb ended by end of line.
--------------------------------------------------------------------------------------------------

Another try:

\newcommand\nameOfMyCommand[1]{\begin{verbatim}#1\end{verbatim} #1}

Another error message:

--------------------------------------------------------------------------------------------------
Runaway argument?
--------------------------------------------------------------------------------------------------

I tried the solution of Ulrich but I obtained the following message:

--------------------------------------------------------------------------------------------------
Runaway argument?


|\emph{toto} titi @ ` $x^2_c\sum$|

\nomDeMaCommande*|\emph{toto} tit\ETC.
! File ended while scanning use of \@tempa.
<inserted text>
\par
<*> essai.tex

I suspect you have forgotten a `}', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type `E' or `X' now and fix your file.

! Emergency stop.
<*> essai.tex
--------------------------------------------------------------------------------------------------

JP

Joseph Wright

unread,
Mar 31, 2008, 7:03:29 AM3/31/08
to

Did you type it exactly as given (line breaks in particular)? For me,
this works very nicely.

Joseph Wright

jeanpier...@gmail.com

unread,
Mar 31, 2008, 8:13:37 AM3/31/08
to
>
> Did you type it exactly as given (line breaks in particular)?  For me,
> this works very nicely.
>
> Joseph Wright- Masquer le texte des messages précédents -
>
> - Afficher le texte des messages précédents -

Actually I have a problem with line breaks but after xheck (I add %
symbol at the end of each line) I have another problem....

My new code
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\documentclass{article}


\usepackage[latin1]{inputenc} % codage des caractères et coupures
cyrilliques

\usepackage{verbatim}
\usepackage{listings}
\usepackage{alltt}

\makeatletter

\newcommand*\nomDeMaCommande{%
\relax%
\ifmmode\hbox\else\leavevmode\null\fi%
\bgroup%
\verb@eol@error%
\let\do\@makeother\dospecials%
\verbatim@font\@noligs%
\@ifstar\@snomDeMaCommande\@nomDeMaCommand%
}%

\newcommand*\@nomDeMaCommande{\@vobeyspaces\frenchspacing
\@snomDeMaCommande­}%
\newcommand*\@snomDeMaCommande[1]{%

\catcode`#1\active%


\lccode`\~`#1%
\gdef\verb@balance@group{%
\verb@egroup\@latex@error{%
\noexpand\verb illegal in command argument%
}\@ehc%

}%
\aftergroup\verb@balance@group%
\lowercase{%
\let ~\verb@egroup%


\def\@tempa##1~{##1~ \scantokens{##1}}%
}%
\@tempa%
}%


\makeatother

\begin{document}

\nomDeMaCommande|\emph{toto} titi @ ` $x^2_c\sum$|

\nomDeMaCommande*|\emph{toto} titi @ ` $x^2_c\sum$|

\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

My new error message
-----------------------------------------------------------------------------------------------
\c@lstlisting=\count95
! Undefined control sequence.
\reserved@c ->\@nomDeMaCommand

l.42 \nomDeMaCommande|


\emph{toto} titi @ ` $x^2_c\sum$|

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.


! LaTeX Error: \verb ended by end of line.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

l.42 ...Commande|\emph{toto} titi @ ` $x^2_c\sum$|

Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.

LaTeX Font Info: External font `cmex10' loaded for size
(Font) <7> on input line 1.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <5> on input line 1.
[1

] (essai.aux) )
Here is how much of TeX's memory you used:
1697 strings out of 95420
22641 string characters out of 1187321
69384 words of memory out of 1073084
4869 multiletter control sequences out of 60000
4154 words of font info for 16 fonts, out of 1000000 for 2000
14 hyphenation exceptions out of 8191
26i,4n,32p,199b,219s stack positions out of 5000i,500n,10000p,200000b,
32768s

Output written on essai.dvi (1 page, 636 bytes).
-----------------------------------------------------------------------------------------------

Thanks for your help!!
jp

Joseph Wright

unread,
Mar 31, 2008, 9:42:22 AM3/31/08
to

You missed the e off:

\@ifstar\@snomDeMaCommande\@nomDeMaCommande

in your changes. However, the percent signs are not needed - why did
you add them?

Joseph Wright

jeanpier...@gmail.com

unread,
Mar 31, 2008, 10:49:04 AM3/31/08
to
On 31 mar, 15:42, Joseph Wright <joseph.wri...@morningstar2.co.uk>
wrote:
> > ---------------------------------------------------------------------------­--------------------
> > ---------------------------------------------------------------------------­--------------------

>
> > Thanks for your help!!
> > jp
>
> You missed the e off:
>
>    \@ifstar\@snomDeMaCommande\@nomDeMaCommande
>
> in your changes.  However, the percent signs are not needed - why did
> you add them?
>
> Joseph Wright- Masquer le texte des messages précédents -
>
> - Afficher le texte des messages précédents -

Thank you Joseph and Ulrich !!
After the correction of my mistakes this works !!!

jp

Ulrich Diez

unread,
Mar 31, 2008, 12:27:02 PM3/31/08
to
jeanpier...@gmail.com wrote:

> I tried the solution of Ulrich but I obtained the following message:
>
> --------------------------------------------------------------------------------------------------
> Runaway argument?
> |\emph{toto} titi @ ` $x^2_c\sum$|
>
> \nomDeMaCommande*|\emph{toto} tit\ETC.
> ! File ended while scanning use of \@tempa.
> <inserted text>
> \par
> <*> essai.tex
>
> I suspect you have forgotten a `}', causing me
> to read past where you wanted me to stop.
> I'll try to recover; but if the error is serious,
> you'd better type `E' or `X' now and fix your file.

I tested my solution once more and at my place it still works.

Your posting-header indicates that you use google-groups as
usenet-interface.

The google-web-interface tends to distort and to destroy
macro-code by reformatting paragraphs and line-breaks.

Make sure that for copy'n-paste-stuff the google-web-interface
shows the message in "original format".

<OT> If I made many mistakes in my French-language-posting,
feel free to tell me about them for the sake of improving my
French-language-skills ;-) </OT>

Ulrich

jeanpier...@gmail.com

unread,
Mar 31, 2008, 1:40:29 PM3/31/08
to
You are right Ulrich about google-web-interface: you are the boss :)!

Don't worry, I understand better your French rather than your latex
code :)

<correction>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
(Il y a longtemps <> j'ai <appris> quelques mots de la langue
française...
OR <Ca fait longtemps que j'ai appris quelques mots en français...>)

"\verb" interprete son argument littéralement <en> _<lisant>
l'argument du fichier-en <entrée>_ après <il> change les catcodes <de>
quelques caractères.

L'argument de la macro "\nomDeMaCommande" est passé à la macro
"\verb".

En conséquence l'argument de la macro "\verb" est lu par la macro
"\nomDeMaCommande".

Mais pendant que "\nomDeMaCommande" lit son argument,

il n'y a pas des <changement> des catcodes...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Usually, the argument of verb must contain only one line, but you
could extend \nomDeMaCommande in order to the argument be able to
contain more lines, e.g.:

\nomDeMaCommande|\emph{toto} titi @ `

$x^2_c$
$\sum$|

jp

PS: I know I made lot of mistakes in english then feel free to tell me
about the biggest :)

0 new messages