# How can I force pairs of brackets [][] to be closer to each other in \texttt?

\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?

-
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
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

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}


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?

-
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