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'm trying to create a documentation listing similar to that used by MSDN. Here was my first attempt at that:

\subsubsection{User Default Page URL}
\begin{description}
\item[Rationale] This is the default page displayed to a user when
(s)he opens a new window or tab in Microsoft's Internet Explorer browser.
\item[Data Sources] \begin{verbatim}
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer]
"Default_Page_URL"="${url}"
\end{verbatim}
\item[Log Format] \begin{verbatim} 
uDefaultPageUrl=${url}
\end{verbatim}
\item[Description] The variable \var{url} is escaped using the URL
escaping scheme defined in \ref{urlescape}.
\end{description}

Which produces:

example output

Of course, this is wrong behavior -- the registry key bit needs to go on it's own, not pushed over to the right on the first line. I tried following the instructions on this question, which left this:

\subsubsection{User Default Page URL}
\begin{description}
\item[Rationale] \hfill \\ This is the default page displayed to a user when
(s)he opens a new window or tab in Microsoft's Internet Explorer browser.
\item[Data Sources] \hfill \\ \begin{verbatim}
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer]
"Default_Page_URL"="${url}"
\end{verbatim}
\item[Log Format] \hfill \\ \begin{verbatim} 
uDefaultPageUrl=${url}
\end{verbatim}
\item[Description] \hfill \\ The variable \var{url} is escaped using the URL
escaping scheme defined in \ref{urlescape}.
\end{description}

producing:

example longer output

This is bad because now there's a huge space before the verbatim text. Also, XeTeX decided to complain quite a bit about bad boxes on this one.

I've tried several "massagings" of this -- such as removing the explicit newline after the \hline on Verbatim environments only. That shrinks the space, but not enough -- it still looks like a huge gaping hole.

How would one fix this?

EDIT: In response to the comment:

\subsubsection{User Default Page URL}

\begin{description}
\item[Rationale] This is the default page displayed to a user when
(s)he opens a new window or tab in Microsoft's Internet Explorer browser.
\item[Data Sources] \hfill

\begin{verbatim}
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer]
"Default_Page_URL"="${url}"
\end{verbatim}
\item[Log Format]
\begin{verbatim} 
uDefaultPageUrl=${url}
\end{verbatim}
\item[Description] The variable \var{url} is escaped using the URL
escaping scheme defined in \ref{urlescape}.

\end{description}

produces:

Still spaced

share|improve this question

2 Answers 2

Perhaps there is better method, but it seems that if you eliminate the \\ and include a \vspace{-\baselineskip} before the verbatim environment you get reasonable looking results:

enter image description here

\documentclass{article}
\newcommand*{\var}[1]{\texttt{#1}}%  Macro definition not provided in MWE

\begin{document}
\subsubsection{User Default Page URL}

\begin{description}
\item[Rationale] \hfill 

This is the default page displayed to a user when
(s)he opens a new window or tab in Microsoft's Internet Explorer browser.
\item[Data Sources] \hfill\vspace{-\baselineskip}

\begin{verbatim}
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer]
"Default_Page_URL"="${url}"
\end{verbatim}
\item[Log Format] \hfill \vspace{-\baselineskip}
%
\begin{verbatim} 
uDefaultPageUrl=${url}
\end{verbatim}
\item[Description] \hfill 

The variable \var{url} is escaped using the URL
escaping scheme defined in \ref{urlescape}.
\end{description}
\end{document} 
share|improve this answer
    
Sorry, forgot to include var :) That looks awesome.. thank you. +1. –  Billy ONeal Feb 7 '12 at 1:09

Similar to the solution provided in Control vertical space before and after verbatim environment?, here is a version of your MWE that is properly aligned:

enter image description here

% Reference: http://tex.stackexchange.com/questions/43638/
% Related: http://tex.stackexchange.com/questions/43331/
\documentclass{article}
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\makeatletter
\preto{\@verbatim}{\topsep=0pt \partopsep=0pt}
\makeatother
\newcommand{\var}[1]{\bgroup\ttfamily\string$\string{#1\string}\egroup}%$
\begin{document}

\setcounter{section}{3}\setcounter{subsection}{2}% Just for this example
\subsubsection{User Default Page URL}

\begin{description}
\item[Rationale] This is the default page displayed to a user when
(s)he opens a new window or tab in Microsoft's Internet Explorer browser.
\item[Data Sources] \hspace*{\fill} \\[-\dimexpr\baselineskip+\parskip\relax]
\begin{verbatim}
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer]
"Default_Page_URL"="${url}"
\end{verbatim}
\item[Log Format] \hspace*{\fill} \\[-\dimexpr\baselineskip+\parskip\relax]
\begin{verbatim} 
uDefaultPageUrl=${url}
\end{verbatim}
\item[Description] The variable \var{url} is escaped using the URL
escaping scheme defined in~3.2.1.

\end{description}
\end{document}

Here is a comparable view using inline verbatim (via \verb) to show the corresponding vertical alignment. On the left is a section of the above output, while the code below is added to the right:

enter image description here

\documentclass{article}
\newcommand{\var}[1]{\bgroup\ttfamily\string$\string{#1\string}\egroup}%$
\begin{document}

\setcounter{section}{3}\setcounter{subsection}{2}% Just for this example
\subsubsection{User Default Page URL}

\begin{description}
\item[Rationale] This is the default page displayed to a user when
(s)he opens a new window or tab in Microsoft's Internet Explorer browser.
\item[Data Sources] \hspace*{\fill} \\
\verb|[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer]| \\
\verb|"Default_Page_URL"="${url}"|
\item[Log Format] \hspace*{\fill} \\
\verb|uDefaultPageUrl=${url}|
\item[Description] The variable \var{url} is escaped using the URL
escaping scheme defined in~3.2.1.

\end{description}
\end{document}
share|improve this answer
    
I'm confused.. what's the difference in the output? –  Billy ONeal Feb 7 '12 at 6:23
    
@BillyONeal: The difference between my output in the first example and that of @ PeterGrill's answer is minimal. However, when you put his and mine next to one another, you'll notice the difference. The reason being that the verbatim environment is set as a list (trivlist), which adds a little space above/at the beginning (see the linked post). There's no difference in the output of the last example even though the left image is created using the verbatim environment, compared to the inline \verb for the right image. –  Werner Feb 7 '12 at 6:27
    
Ah, makes sense. (Sorry for being a dullard at such things) –  Billy ONeal Feb 7 '12 at 6:33
    
@BillyONeal: More specific to @ PeterGrill's answer: You'll notice that the height from the item label to the first line is smaller in the verbatim items than in the regular items. As I mentioned this may be negligible to most people. –  Werner Feb 7 '12 at 6:43
    
Yeah; if I was publishing a book or something then this does look more consistent. Unfortunately it's a lot more code to do per-entry :( –  Billy ONeal Feb 7 '12 at 6:55

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.