1

In LyX, I want to center a title for my "Chapter One". However, using the Automatic sectioning i.e. "part" for example can only have the section title left aligned. I chose "Standard" so I can manipulate the paragraph to center align. It however can't appear on the TOC. Please assist. Document class used is Article(Standard Class).

  • Welcome to TeX.SX! Can you post the LaTeX source of a small example that shows your current approach? – gernot Sep 6 '16 at 22:35
  • I am using Lyx, which is a Latex editor. Much of it is similar to MS Word where commands are simply "drop-down-menu" based. I have not used any "codes" so to speak. – George Kariuki Sep 6 '16 at 22:55
  • However, to shed more light, in developing a document, I would wish to have a Table of Contents. Each section more or less appear in the TOC list. The default style of each paragraph can be selected on a drop-down-menu on the tool bar. I however do not want the "uneditable" left aligning of section headers. Using a standard option of the paragraph so as to centre the header renders the section header not included in the TOC. What should I do to ensure I add this content on the TOC? – George Kariuki Sep 6 '16 at 23:01
  • The closest I came to help was from (wiki.lyx.org/FAQ/TOC) option 4. – George Kariuki Sep 6 '16 at 23:04
2

Instead of using a Part for setting your section, use Section and add the following to your Document > Settings... > LaTeX Preamble:

\usepackage{sectsty}
\sectionfont{\normalfont\large\bfseries\centering}

The font setting above are the default associated with the article class.

While the visual inside LyX won't display the sections as being centered

enter image description here

the output will:

enter image description here

If you want it to show inside LyX as well, you can add the following Document > Settings... > Local Layout:

Format 60

Style Section
  LatexType    Command
  LatexName    sect1
  InnerTag     "title"
  CommandDepth 2
  Align        Center
End

Style Section*
    CopyStyle  Section
    Margin     Static
    LatexName  bridgehead
    LatexType  Paragraph
    InnerTag   "!-- --"
    LabelType  No_Label
    ResetArgs  1
    LatexParam renderas="sect1"
End

This results in the following display in LyX:

enter image description here

  • Thank you for this. This helps but what should I do to have say "Chapter One" and not "1. Chapter One"? If I use the sectioning options with * "asterisks" the number disappears but the subsection numbering is altered. I want to maintain numbering for subsection but have no number preceding the section such that "introduction" after "Chapter One" would read "1.1. Introduction" and so on for other subsections. Thanks you. – George Kariuki Sep 9 '16 at 0:23
  • I am a new user of Stackexchange with no idea on how to attach a screen shot for better elaboration. – George Kariuki Sep 9 '16 at 0:25
  • @GeorgeKariuki: That's doable inside LaTeX, which means you can place some stuff in your Document > Settings... > LaTeX Preamble. However, I'm not sure how to change that on the display side of LyX. That is, things may still print the way you see them in the image above, but your output to PDF will show as you want it. Would that be okay? – Werner Sep 9 '16 at 0:30
  • Yes that would be ok. I know how to work in the lyx preamble though I don't know which package to use so as I get the output as I put it. – George Kariuki Sep 9 '16 at 8:34
  • @GeorgeKariuki: See if adding \let\oldsection\section \renewcommand{\section}{\refstepcounter{section}\oldsection*} to your Document > Settings... > LaTeX Preamble solves your problem (in the resulting PDF). – Werner Sep 10 '16 at 8:55

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.