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.
\documentclass{article}   
\begin{document}
Normal margin here. Normal margin here. Normal margin here.
Normal margin here. Normal margin here. Normal margin here. Normal margin here.

Abcdefgh abcdefgh abcdefgh abcdefgh abcdefgh abcd: \texttt{float[][]} and
\texttt{double[][]}.
\end{document}

As you can see [] is far from other []. How can I get them closer to each other? What is more, double[][] extends beyond the margin line. How could this be written better?

I'm using minted package. Is it possible to write small code samples inline using it?

enter image description here

share|improve this question
2  
It's an artifact of monospaced font. Compare the following \documentclass{article} \begin{document} % \verb+double||||+ % \verb+double[][]+. \end{document} .(Introduce new lines at the comments such that they align vertically to see the location of each character) –  percusse May 19 '12 at 7:26
1  
as @percusse says the distinguishing feature of a monospace font is that all the characters are the same width, so W and . are the same width. If you do not want that, rather than adding spacing between [] perhaps you would prefer a different font, say \textsf{float[][]} –  David Carlisle May 19 '12 at 8:08
add comment

1 Answer

up vote 10 down vote accepted

If it doesn't occur very often or you can use search and replace you can add a negative space by yourself to compensate for it:

\documentclass{article}   
\begin{document}
Normal margin here. Normal margin here. Normal margin here.
Normal margin here. Normal margin here. Normal margin here. Normal margin here.

Abcdefgh abcdefgh abcdefgh abcdefgh abcdefgh abcd: \texttt{float[]$\!$[]} and
\texttt{double[]\kern-.2em[]}.
\end{document}

Result

In theory it should also be possible to change the kerning of ] and [, but I can't tell you if this can be done with some reasonable amount of work. Maybe the microtype package can help?

share|improve this answer
1  
if the kerning of the brackets were changed, it would no longer be a monospace font. –  barbara beeton May 19 '12 at 12:17
    
Changing the kerning between two characters is not easy in LaTeX. microtype can change a character's kerning, but that will influence the kerning between that character and all other characters. Your solution is simple and it works, i.e. most likely the best. –  Sveinung May 19 '12 at 12:27
add comment

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.