7

I have to following code from examples which seems to work as I need.

I have been reading about literate and can fix my long lines but would like to understand why the '0'. Can't seem to make sense of syntax.

literate={\#}}{0\discretionary{\#}{}{}},

In the following example, the code will only compile if the zero '0' is included before the \discretionary call. It not obvious in my very limited knowledge but curious as to why it is needed?

The setup of the 'literate' key does only compile if I uncomment the line above to it.

The error message is:

! Missing number, treated as zero.
<to be read again>
\discretionary
A number should have been here; I inserted '0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
! Missing number, treated as zero.

Here's a sample document:

\documentclass[10pt]{article} 
\usepackage{listings} 
\begin{document} 
\lstset{ 
breakatwhitespace=true,
%literate={\#}{}{0\discretionary{\#}{}{}}, 
literate={\#}{}{\discretionary{\#}{}{}} % not working 
}  
\begin{lstlisting} 
         #############################################################################‌########################################################################33      
\end{lstlisting} 
\end{document} 
2
  • 1
    Welcome to TeX.SX! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – Alan Munn
    Commented Nov 6, 2013 at 5:00
  • 1
    @Dale rather than add the example in the comments, you can edit your question and add it there. I've added it in, but it's not quite right. Perhaps you can fix it.
    – Alan Munn
    Commented Nov 6, 2013 at 5:17

1 Answer 1

2

The syntax of literate is

{ replace }{ replacement text }{ length }

the third argument specifies the length of the replacement text which is empty in your example. The reason why you have to insert a 0

2
  • Thanks, I did find that syntax . The length part would be {0\discretionary{\#}{}{}} in the example but does "0\discretionary{\#}{}{}" resolve to a number or a 0 with a string after it?
    – Dale
    Commented Nov 6, 2013 at 8:15
  • To me it makes no sense to use the discretionary part because you simply remove the #.
    – user2478
    Commented Nov 6, 2013 at 8:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .