Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am working on special character handling and my text is having % as one the special character which is treated as comment and anything after that is not printed. I m using verb as suggested in my previous thread but still pblm.

How to handle special characters in LaTeX?

Below is my code.

\documentclass[11pt,table,a4paper]{article}
\usepackage{array,ragged2e}
\usepackage[scaled]{uarial}
\usepackage[T1]{fontenc}
\begin{document}
\begin{minipage}{0.3\linewidth}
\def\verbatim@font{\normalfont\ua1} 
This is my sample text for checking % character. I found whereever there   is     % character it is treated as comment and nothing gets printed after this. How can i fix this pblm. I m using verb still getting same pblm. pls help me how can i fix this pblm.
\end{minipage}
\end{document}
share|improve this question
    
Not only do you need to define/set the verbatim font, you need to select/use it in a verbatim environment (say). –  Werner Aug 17 '12 at 2:02
4  
Are you really want to use % in some code lising? If this is only a normal text, just use \%. And you may need to read a short but complete LaTeX tutorial first. –  Leo Liu Aug 17 '12 at 2:14

1 Answer 1

To typeset verbatim material you need to use, for example, the verbatim environment (in your code snippet you only selected a font for verbatim material) and manually introduce line breaks (I commented out some lines because I don't have uarial.sty):

\documentclass[11pt,table,a4paper]{article}
\usepackage{array,ragged2e}
%\usepackage[scaled]{uarial}
\usepackage[T1]{fontenc}

\makeatletter
%\def\verbatim@font{\normalfont\ua1} 
\makeatother

\begin{document}

\begin{verbatim}
This is my sample text for checking % character. I found 
whereever there  is  % character it is treated as comment 
and nothing gets printed after this. How can i fix this pblm. 
I m using verb still getting same pblm. pls help me how 
can i fix this pblm.
\end{verbatim}

\end{document}

enter image description here

The fancyvrb packages offers more possibilities and enhanced verbatim environments/commands; the listings package extends even more the possibilities.

If all that you need is to typeset the percentage character, use \%:

\documentclass[11pt,table,a4paper]{article}
\usepackage{array,ragged2e}
%\usepackage[scaled]{uarial}
\usepackage[T1]{fontenc}

\begin{document}
\begin{minipage}{0.3\linewidth}
This is my sample text for checking \% character. I found whereever there   is   \% character it is treated as comment and nothing gets printed after this. How can i fix this pblm. I m using verb still getting same pblm. pls help me how can i fix this pblm.
\end{minipage}
\end{document}

enter image description here

share|improve this answer
    
using \begin{verbatim} \end{verbatim} generates no newline and output text is in typewriter output format so i cannot use it. –  manish Aug 17 '12 at 2:16
2  
@manish then simply write \% (with a backslash). –  Gonzalo Medina Aug 17 '12 at 2:18
1  
@manish: What do you mean by "newline". Do you want an automatic line-break? Inside verbatim everything is typeset as-is. Sure you can change the font to whatever you want, but it doesn't do line-breaks. –  Werner Aug 17 '12 at 2:21
    
@manish I've updated my answer. –  Gonzalo Medina Aug 17 '12 at 2:22
    
@Werner apparently all that is required is how to typeset % in normal text. –  Gonzalo Medina Aug 17 '12 at 2:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.