LyXvertical space before and after section heading

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
np2333
Posts: 10
Joined: Tue Oct 06, 2015 5:19 pm

vertical space before and after section heading

Post by np2333 »

Hi,

I am trying to use the package titlesec to create vertical spaces before and after titles of sections in my document. I have tried the following commands:

Code: Select all

\titlespacing{\section}{0pc}{5.5ex plus 15ex minus 9ex}{3pc}
\titlespacing{\section}{0pc}{100pc}{3pc}
Both of them seem to work for the space after the title (i.e the last parenthesis with 3pc in the above document), but they dont work for the space before the title. Any help will be greatly appreciated.

Thanks

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

vertical space before and after section heading

Post by Johannes_B »

Would you mind posting a minimal working example for us to reproduce your issue?
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
np2333
Posts: 10
Joined: Tue Oct 06, 2015 5:19 pm

Re: vertical space before and after section heading

Post by np2333 »

thanks. An example is attached. The issue i am grappling with is how to get the required vertical space between the text in section 2 and the heading of section 3. (Also, if there is a way to adjust font size for section heading that would be great to know too)

Thanks
Attachments
titlexample2.lyx
(7.92 KiB) Downloaded 1169 times
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

vertical space before and after section heading

Post by Johannes_B »

LyX is supposed to be a tool for experienced LaTeX-users.

What we have here, is simply madness. Sorry, please don't feel offended but that preamble looks like a madman has assembled it. Why are you keeping all those commented lines? This is insane.

To the point: The spacing isn't right, and the font size doesn't match. But apparently, this is what you wanted by clicking some buttons without care in LyX.

Code: Select all

\begin{document}

\section{{\normalsize{}Introduction}}

\begin{onehalfspace}
asda
\end{onehalfspace}

asdas

asdasd

asda

\begin{onehalfspace}
sda
\end{onehalfspace}

asdas

asdasd

asda

\begin{onehalfspace}
sda
\end{onehalfspace}

asdas

asdasd

asda

\begin{onehalfspace}
sda
\end{onehalfspace}

asdas

asdasd

\begin{onehalfspace}

\section{{\normalsize{}Section 2}}
\end{onehalfspace}

section 2 text

\begin{onehalfspace}

\section{{\normalsize{}\label{sec:Model}Section3}}
\end{onehalfspace}

\begin{onehalfspace}
dsdsds text\end{onehalfspace}

\end{document}
Get rid of that \normalsize stuff and all those freaking onehalfspace environments. Your document is typeset onehalfspaced already.




Another thing: Please use package blindtext to create some blindtext. Or use your imagination and write up a few sentences but don't throw careless asdf fsad ffsa dfsa at us.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
np2333
Posts: 10
Joined: Tue Oct 06, 2015 5:19 pm

Re: vertical space before and after section heading

Post by np2333 »

Thanks for you response. I agree that the preamble with all the commented lines is a bit confusing and I have fixed that now.

On your (I must say rather polite) suggestion to "Get rid of that \normalsize stuff and all those freaking onehalfspace environments", I think the reason why I posted this in the first place was that I am not sure how to do it, i.e which command in my preamble is leading to these one half spacings that are interfering with titling.

Point about using blindtext or some other text is well taken. Apologies on that.

Look forward to your response.

ps "LyX is supposed to be a tool for experienced LaTeX-users." I am not sure I agree. For people like me without much of a background in programming or computer languages, lyx provides a simple way to access the latex capabilities. Perhaps as an expert you view it differently.
Attachments
titleexample3.lyx
(3.5 KiB) Downloaded 685 times
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

vertical space before and after section heading

Post by Johannes_B »

I minimized your code, please open in writelatex and do as i say: Get rid of the freaking onehalfspace-environments, the document is onehalfspaced anyway.

Code: Select all

\documentclass{article}
\usepackage{setspace}
\onehalfspacing

\usepackage{showframe}
\usepackage{titlesec}
\titlespacing{\section}{0pc}{10pc}{3pc}

\begin{document}

\section{{\normalsize{}Introduction}}

\begin{onehalfspace}
Text check
\end{onehalfspace}

text check

text check

text check

text check

text check

text check

text check

text check

text check

text check

\begin{onehalfspace}

\section{{\normalsize{}Section 2}}
\end{onehalfspace}

section 2 text

\begin{onehalfspace}

\section{{\normalsize{}\label{sec:Model}Section3}}
\end{onehalfspace}

\begin{onehalfspace}
dsdsds text\end{onehalfspace}

\end{document}
You may be interested what a LyX developer thinks about the LaTeX basics.

The level that you as an author are writing, has nothing to do with programming.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
np2333
Posts: 10
Joined: Tue Oct 06, 2015 5:19 pm

Re: vertical space before and after section heading

Post by np2333 »

While I see that I can open this document in writelatex or any other latex editor and get rid of all the half spacings I want, this is an example file. I need to implement this in a much larger file which is set up in lyx, so if there is a way to do this directly from lyx it would be helpful.

Thanks for sending the link
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: vertical space before and after section heading

Post by Johannes_B »

LyX has inserted those lines because (i guess) you clicked some button. Unclick the button or revert clicking the button.

How to do this in LyX i cannot tell you, i just open up LyX most of the time to export user code to LaTeX and provide some fix. This time, i can point out just the cause of problems.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
torbjorn t.
Posts: 162
Joined: Wed Jun 17, 2009 10:18 pm

Re: vertical space before and after section heading

Post by torbjorn t. »

The onehalfspacing environments have been added to individual paragraphs because, somehow, the paragraph settings has been changed. Seems the simplest way of removing it is to select all the text, right click -> Paragraph settings. Set Line spacing to Default if it isn't already, and click Apply.

If you've customized some other paragraph setting somewhere, that will likely be reset by this, so don't be surprised if something changes. You can of course do this one paragraph at a time, but that's boring.

I don't know where the \normalsizes in section headings come from, but select the heading, right click -> Text style -> Customized. From the Size dropdown, select Reset and click OK. That seems to remove those.
np2333
Posts: 10
Joined: Tue Oct 06, 2015 5:19 pm

Re: vertical space before and after section heading

Post by np2333 »

That was useful. Problem solved. Thanks a lot
Post Reply