How to center section when using titleformat{section}?











up vote
2
down vote

favorite
1












I decided to use usepackage[center]{titlesec} in order to center my sections, but I don't want them displaying the chapter/section numbering in the chapter/section headings so I applied the titleformat. But with this new macro, it erased the [center] command.



documentclass[14pt]{memoir}

usepackage[center]{titlesec}
usepackage{lipsum}

titleformat{chapter}
{Largebfseries}
{}
{0pt}
{huge}

titleformat{section}
{Largebfseries}
{}
{0pt}
{large}

begin{document}

tableofcontents

chapter{This shouldn't be centered}
clearpage
section{This should be centered}
lipsum[1]
subsection{This should be centered}
Nothing to see here.
end{document}


Result:



enter image description here










share|improve this question
























  • It worked but generated a /par error on compilation.
    – Xyd
    Jan 19 '16 at 18:56










  • See About memoir and titlesec incompatibility
    – egreg
    Jan 19 '16 at 18:57















up vote
2
down vote

favorite
1












I decided to use usepackage[center]{titlesec} in order to center my sections, but I don't want them displaying the chapter/section numbering in the chapter/section headings so I applied the titleformat. But with this new macro, it erased the [center] command.



documentclass[14pt]{memoir}

usepackage[center]{titlesec}
usepackage{lipsum}

titleformat{chapter}
{Largebfseries}
{}
{0pt}
{huge}

titleformat{section}
{Largebfseries}
{}
{0pt}
{large}

begin{document}

tableofcontents

chapter{This shouldn't be centered}
clearpage
section{This should be centered}
lipsum[1]
subsection{This should be centered}
Nothing to see here.
end{document}


Result:



enter image description here










share|improve this question
























  • It worked but generated a /par error on compilation.
    – Xyd
    Jan 19 '16 at 18:56










  • See About memoir and titlesec incompatibility
    – egreg
    Jan 19 '16 at 18:57













up vote
2
down vote

favorite
1









up vote
2
down vote

favorite
1






1





I decided to use usepackage[center]{titlesec} in order to center my sections, but I don't want them displaying the chapter/section numbering in the chapter/section headings so I applied the titleformat. But with this new macro, it erased the [center] command.



documentclass[14pt]{memoir}

usepackage[center]{titlesec}
usepackage{lipsum}

titleformat{chapter}
{Largebfseries}
{}
{0pt}
{huge}

titleformat{section}
{Largebfseries}
{}
{0pt}
{large}

begin{document}

tableofcontents

chapter{This shouldn't be centered}
clearpage
section{This should be centered}
lipsum[1]
subsection{This should be centered}
Nothing to see here.
end{document}


Result:



enter image description here










share|improve this question















I decided to use usepackage[center]{titlesec} in order to center my sections, but I don't want them displaying the chapter/section numbering in the chapter/section headings so I applied the titleformat. But with this new macro, it erased the [center] command.



documentclass[14pt]{memoir}

usepackage[center]{titlesec}
usepackage{lipsum}

titleformat{chapter}
{Largebfseries}
{}
{0pt}
{huge}

titleformat{section}
{Largebfseries}
{}
{0pt}
{large}

begin{document}

tableofcontents

chapter{This shouldn't be centered}
clearpage
section{This should be centered}
lipsum[1]
subsection{This should be centered}
Nothing to see here.
end{document}


Result:



enter image description here







horizontal-alignment titlesec






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 at 4:05









LCarvalho

969317




969317










asked Jan 19 '16 at 18:40









Xyd

142111




142111












  • It worked but generated a /par error on compilation.
    – Xyd
    Jan 19 '16 at 18:56










  • See About memoir and titlesec incompatibility
    – egreg
    Jan 19 '16 at 18:57


















  • It worked but generated a /par error on compilation.
    – Xyd
    Jan 19 '16 at 18:56










  • See About memoir and titlesec incompatibility
    – egreg
    Jan 19 '16 at 18:57
















It worked but generated a /par error on compilation.
– Xyd
Jan 19 '16 at 18:56




It worked but generated a /par error on compilation.
– Xyd
Jan 19 '16 at 18:56












See About memoir and titlesec incompatibility
– egreg
Jan 19 '16 at 18:57




See About memoir and titlesec incompatibility
– egreg
Jan 19 '16 at 18:57










2 Answers
2






active

oldest

votes

















up vote
2
down vote



accepted










like this ? :



documentclass[14pt]{memoir}

usepackage[center]{titlesec}
usepackage{lipsum}

titleformat{chapter}
{centeringLargebfseries} % format
{}% label
{0pt} % sep
{huge}

setcounter{secnumdepth}{0}

begin{document}

tableofcontents

chapter{This shouldn't be centered}
clearpage
section{This should be centered}
lipsum[1]
subsection{This should be centered}
Nothing to see here.
end{document}


Result:
enter image description here






share|improve this answer























  • I tried it and saw that chapter{This shouldn't be centered} actually centered. Oh well but once I removed centering it was all good!... But the numbers came back.
    – Xyd
    Jan 19 '16 at 18:56












  • I found an answer elsewhere and used setsecnumdepth{none} maxsecnumdepth{none} instead of setcounter{secnumdepth}{0} and now it worked (as for removing the darn numbers).
    – Xyd
    Jan 19 '16 at 19:18


















up vote
2
down vote













You shouldn't use titlesec with memoir, see About memoir and titlesec incompatibility



documentclass[14pt]{memoir}

usepackage{lipsum}

setsecheadstyle{centeringLargebfseries}
setsubsecheadstyle{centeringlargebfseries}

setsechook{setsecnumformat{csname the##1endcsname }}

begin{document}

tableofcontents

chapter{This shouldn't be centered}
section{This should be centered}
lipsum[1]
subsection{This should be centered}
Nothing to see here.
end{document}


enter image description here






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "85"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f288424%2fhow-to-center-section-when-using-titleformat-section%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote



    accepted










    like this ? :



    documentclass[14pt]{memoir}

    usepackage[center]{titlesec}
    usepackage{lipsum}

    titleformat{chapter}
    {centeringLargebfseries} % format
    {}% label
    {0pt} % sep
    {huge}

    setcounter{secnumdepth}{0}

    begin{document}

    tableofcontents

    chapter{This shouldn't be centered}
    clearpage
    section{This should be centered}
    lipsum[1]
    subsection{This should be centered}
    Nothing to see here.
    end{document}


    Result:
    enter image description here






    share|improve this answer























    • I tried it and saw that chapter{This shouldn't be centered} actually centered. Oh well but once I removed centering it was all good!... But the numbers came back.
      – Xyd
      Jan 19 '16 at 18:56












    • I found an answer elsewhere and used setsecnumdepth{none} maxsecnumdepth{none} instead of setcounter{secnumdepth}{0} and now it worked (as for removing the darn numbers).
      – Xyd
      Jan 19 '16 at 19:18















    up vote
    2
    down vote



    accepted










    like this ? :



    documentclass[14pt]{memoir}

    usepackage[center]{titlesec}
    usepackage{lipsum}

    titleformat{chapter}
    {centeringLargebfseries} % format
    {}% label
    {0pt} % sep
    {huge}

    setcounter{secnumdepth}{0}

    begin{document}

    tableofcontents

    chapter{This shouldn't be centered}
    clearpage
    section{This should be centered}
    lipsum[1]
    subsection{This should be centered}
    Nothing to see here.
    end{document}


    Result:
    enter image description here






    share|improve this answer























    • I tried it and saw that chapter{This shouldn't be centered} actually centered. Oh well but once I removed centering it was all good!... But the numbers came back.
      – Xyd
      Jan 19 '16 at 18:56












    • I found an answer elsewhere and used setsecnumdepth{none} maxsecnumdepth{none} instead of setcounter{secnumdepth}{0} and now it worked (as for removing the darn numbers).
      – Xyd
      Jan 19 '16 at 19:18













    up vote
    2
    down vote



    accepted







    up vote
    2
    down vote



    accepted






    like this ? :



    documentclass[14pt]{memoir}

    usepackage[center]{titlesec}
    usepackage{lipsum}

    titleformat{chapter}
    {centeringLargebfseries} % format
    {}% label
    {0pt} % sep
    {huge}

    setcounter{secnumdepth}{0}

    begin{document}

    tableofcontents

    chapter{This shouldn't be centered}
    clearpage
    section{This should be centered}
    lipsum[1]
    subsection{This should be centered}
    Nothing to see here.
    end{document}


    Result:
    enter image description here






    share|improve this answer














    like this ? :



    documentclass[14pt]{memoir}

    usepackage[center]{titlesec}
    usepackage{lipsum}

    titleformat{chapter}
    {centeringLargebfseries} % format
    {}% label
    {0pt} % sep
    {huge}

    setcounter{secnumdepth}{0}

    begin{document}

    tableofcontents

    chapter{This shouldn't be centered}
    clearpage
    section{This should be centered}
    lipsum[1]
    subsection{This should be centered}
    Nothing to see here.
    end{document}


    Result:
    enter image description here







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 13 at 0:38









    LCarvalho

    969317




    969317










    answered Jan 19 '16 at 18:51









    flav

    3,3971625




    3,3971625












    • I tried it and saw that chapter{This shouldn't be centered} actually centered. Oh well but once I removed centering it was all good!... But the numbers came back.
      – Xyd
      Jan 19 '16 at 18:56












    • I found an answer elsewhere and used setsecnumdepth{none} maxsecnumdepth{none} instead of setcounter{secnumdepth}{0} and now it worked (as for removing the darn numbers).
      – Xyd
      Jan 19 '16 at 19:18


















    • I tried it and saw that chapter{This shouldn't be centered} actually centered. Oh well but once I removed centering it was all good!... But the numbers came back.
      – Xyd
      Jan 19 '16 at 18:56












    • I found an answer elsewhere and used setsecnumdepth{none} maxsecnumdepth{none} instead of setcounter{secnumdepth}{0} and now it worked (as for removing the darn numbers).
      – Xyd
      Jan 19 '16 at 19:18
















    I tried it and saw that chapter{This shouldn't be centered} actually centered. Oh well but once I removed centering it was all good!... But the numbers came back.
    – Xyd
    Jan 19 '16 at 18:56






    I tried it and saw that chapter{This shouldn't be centered} actually centered. Oh well but once I removed centering it was all good!... But the numbers came back.
    – Xyd
    Jan 19 '16 at 18:56














    I found an answer elsewhere and used setsecnumdepth{none} maxsecnumdepth{none} instead of setcounter{secnumdepth}{0} and now it worked (as for removing the darn numbers).
    – Xyd
    Jan 19 '16 at 19:18




    I found an answer elsewhere and used setsecnumdepth{none} maxsecnumdepth{none} instead of setcounter{secnumdepth}{0} and now it worked (as for removing the darn numbers).
    – Xyd
    Jan 19 '16 at 19:18










    up vote
    2
    down vote













    You shouldn't use titlesec with memoir, see About memoir and titlesec incompatibility



    documentclass[14pt]{memoir}

    usepackage{lipsum}

    setsecheadstyle{centeringLargebfseries}
    setsubsecheadstyle{centeringlargebfseries}

    setsechook{setsecnumformat{csname the##1endcsname }}

    begin{document}

    tableofcontents

    chapter{This shouldn't be centered}
    section{This should be centered}
    lipsum[1]
    subsection{This should be centered}
    Nothing to see here.
    end{document}


    enter image description here






    share|improve this answer



























      up vote
      2
      down vote













      You shouldn't use titlesec with memoir, see About memoir and titlesec incompatibility



      documentclass[14pt]{memoir}

      usepackage{lipsum}

      setsecheadstyle{centeringLargebfseries}
      setsubsecheadstyle{centeringlargebfseries}

      setsechook{setsecnumformat{csname the##1endcsname }}

      begin{document}

      tableofcontents

      chapter{This shouldn't be centered}
      section{This should be centered}
      lipsum[1]
      subsection{This should be centered}
      Nothing to see here.
      end{document}


      enter image description here






      share|improve this answer

























        up vote
        2
        down vote










        up vote
        2
        down vote









        You shouldn't use titlesec with memoir, see About memoir and titlesec incompatibility



        documentclass[14pt]{memoir}

        usepackage{lipsum}

        setsecheadstyle{centeringLargebfseries}
        setsubsecheadstyle{centeringlargebfseries}

        setsechook{setsecnumformat{csname the##1endcsname }}

        begin{document}

        tableofcontents

        chapter{This shouldn't be centered}
        section{This should be centered}
        lipsum[1]
        subsection{This should be centered}
        Nothing to see here.
        end{document}


        enter image description here






        share|improve this answer














        You shouldn't use titlesec with memoir, see About memoir and titlesec incompatibility



        documentclass[14pt]{memoir}

        usepackage{lipsum}

        setsecheadstyle{centeringLargebfseries}
        setsubsecheadstyle{centeringlargebfseries}

        setsechook{setsecnumformat{csname the##1endcsname }}

        begin{document}

        tableofcontents

        chapter{This shouldn't be centered}
        section{This should be centered}
        lipsum[1]
        subsection{This should be centered}
        Nothing to see here.
        end{document}


        enter image description here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Apr 13 '17 at 12:35









        Community

        1




        1










        answered Jan 19 '16 at 19:06









        egreg

        698k8518553123




        698k8518553123






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f288424%2fhow-to-center-section-when-using-titleformat-section%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to change which sound is reproduced for terminal bell?

            Can I use Tabulator js library in my java Spring + Thymeleaf project?

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents