Search code examples
latex

LaTeX - Unwanted space above horizontal line


I am forced to choose between two things, but I want both.

What I want to type is something like this:

Name of a list
------------- horizontal line
- Item A
- Item B
- Item B

I am able to do that with the following code:

\textbf{Name of a list}: \\
\rule{\textwidth}{1pt} 
- Item A \\
- Item B  \\
- Item C \\

Here is the result: enter image description here

This is all good so far. Now, say I want the spacing between the different list items to be double spacing. The \doublespacing command. i.e. I wrote:

\textbf{Name of a list}: \\
\rule{\textwidth}{1pt}
\doublespacing
- Item A \\
- Item B  \\
- Item C \\

The problem is, when I do that, the space between "Name of a list" and horizontal line below it become double spaced as well, and I can not get rid of that unwanted space. And here is the result of that: enter image description here

It's subtle, but you can definitely see that there is more space between them now.

How do I get rid of that space? And on a related note, even if I do not want the double spacing between the different items in the list, how can I eliminate the space between "Name of a list" and the horizontal line bellow it? I want them to be really close to each other. Is that possible?

Edit: I am sorry for the unclear code. Here is the full code I used:

\documentclass[a4,12pt] {article}
\usepackage{ragged2e}
\usepackage[margin=0.5in]{geometry}
\setlength{\parindent}{0cm}
\usepackage{setspace}

\begin{document}


\begin{flushleft}

\textbf{Name of a list}: \\ 
\rule{\textwidth}{1pt} 
\doublespacing 
- A \\
- B \\
- C \\


\end{flushleft}



\end{document}

Solution

  • Double spacing starts from the position it is defined. If you want only some portion of the document to be enclosed within it:

    \begin{doublespace} my text \end{doublespace}

    \documentclass[a4,12pt] {article}
    \usepackage{ragged2e}
    \usepackage[margin=0.5in]{geometry}
    \setlength{\parindent}{0cm}
    \usepackage{setspace}
    
    \begin{document}
    
    \begin{flushleft}
    
    \textbf{Name of a list}: \\
    \rule{\textwidth}{1pt}
    - A \\
    \begin{doublespace}
    - B \\
    - C \\
    \end{doublespace}
    
    \end{flushleft}
    
    
     \end{document}