2

I am trying to layout some text to follow the BDD-style scenario format:

Given some condition
    When an action occurs
        And some other action occurs
    Then some result happens

In a previous question it was suggested that I use the tabbing environment to accomplish this format, but when I use the tabbing environment, some of the words overlap.

MWE:

\documentclass[11pt,letter]{article}
\usepackage{enumitem}
\usepackage[hyphens]{url}
\usepackage{hyperref}
\usepackage[T1]{fontenc}     %step 1
\usepackage{tabbing}
\setlist[description]{style=nextline,font=\normalfont}
\begin{document}
\section{Scenario: Valid Login:}
\begin{tabbing}
    \=    \=    \= \kill
Given \> the browser is open to the login page \\
\> When \> a valid username is entered \\
\> \> And \> the valid corresponding password is entered \\
\> \> And \> the sign-in button is clicked \\
\> Then \> the welcome page is displayed. \\
\end{tabbing}
\end{document}

Sample output

BTW: I am using MiKTeX 2.9 on windows 7.

0

Using verbatim might be an easier way...

Code:

\documentclass{article}

\begin{document}

\begin{verbatim}
Given some condition
    When an action occurs
        And some other action occurs
    Then some result happens
\end{verbatim}

\end{document}

Yields:

enter image description here

1

The command \= sets the tab stop. Your first line has effectively no spaces between the tabs, as LaTeX collapses multiple spaces to one and the space immediately after \= is ignored. You could add explicit spaces between these \= with \hspace{...} but then you would have to guess the size of the spaces.

Instead just write \= instead of \> the first time you need any given tabstop:

Given \= the browser is open to the login page \\
\> When \= a valid username is entered \\
\> \> And \= the valid corresponding password is entered \\
\> \> And \> the sign-in button is clicked \\
\> Then \> the welcome page is displayed. \\

Sample output

\documentclass[11pt,letter]{article}
\usepackage{enumitem}
\usepackage[hyphens]{url}
\usepackage{hyperref}
\usepackage[T1]{fontenc}     %step 1
\usepackage{tabbing} %for texlive change to Tabbing
\setlist[description]{style=nextline,font=\normalfont}
\begin{document}
\section{Scenario: Valid Login:}
\begin{tabbing}
Given \= the browser is open to the login page \\
\> When \= a valid username is entered \\
\> \> And \= the valid corresponding password is entered \\
\> \> And \> the sign-in button is clicked \\
\> Then \> the welcome page is displayed. \\
\end{tabbing}
\end{document}

Alternatively, if you want uniform indents, then specify the spacing on the first line and then just tabstop to the position you want in subsequent lines:

\begin{tabbing}
\qquad \= \qquad \= \qquad \= \qquad \= \kill
Given the browser is open to the login page \\
\> When a valid username is entered \\
\> \> And the valid corresponding password is entered \\
\> \> And the sign-in button is clicked \\
\> Then the welcome page is displayed. \\
\end{tabbing}

Here \qquad is \hspace{2em}.

Another version

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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