Changing Typeface of Part












1















How do you change the typeface used for the part environment to an Opentype font?



(In the MWE below, I've used a TrueType font, but the method should be the same).



It appears the standard titlesec method for chapter and section headings doesn't work.



Engine is LuaLaTeX.



M(n-)WE:



documentclass[11pt, a4paper]{book}
usepackage[raggedright]{titlesec}
usepackage{fontspec}

newfontfamilypartfont{Verdana.ttf}
titleformat*{part}{partfont}

newfontfamilychapterfont{Verdana.ttf}
titleformat*{chapter}{chapterfont}

begin{document}
part{Hello world.}
chapter{Hello again, world.}
end{document}









share|improve this question



























    1















    How do you change the typeface used for the part environment to an Opentype font?



    (In the MWE below, I've used a TrueType font, but the method should be the same).



    It appears the standard titlesec method for chapter and section headings doesn't work.



    Engine is LuaLaTeX.



    M(n-)WE:



    documentclass[11pt, a4paper]{book}
    usepackage[raggedright]{titlesec}
    usepackage{fontspec}

    newfontfamilypartfont{Verdana.ttf}
    titleformat*{part}{partfont}

    newfontfamilychapterfont{Verdana.ttf}
    titleformat*{chapter}{chapterfont}

    begin{document}
    part{Hello world.}
    chapter{Hello again, world.}
    end{document}









    share|improve this question

























      1












      1








      1








      How do you change the typeface used for the part environment to an Opentype font?



      (In the MWE below, I've used a TrueType font, but the method should be the same).



      It appears the standard titlesec method for chapter and section headings doesn't work.



      Engine is LuaLaTeX.



      M(n-)WE:



      documentclass[11pt, a4paper]{book}
      usepackage[raggedright]{titlesec}
      usepackage{fontspec}

      newfontfamilypartfont{Verdana.ttf}
      titleformat*{part}{partfont}

      newfontfamilychapterfont{Verdana.ttf}
      titleformat*{chapter}{chapterfont}

      begin{document}
      part{Hello world.}
      chapter{Hello again, world.}
      end{document}









      share|improve this question














      How do you change the typeface used for the part environment to an Opentype font?



      (In the MWE below, I've used a TrueType font, but the method should be the same).



      It appears the standard titlesec method for chapter and section headings doesn't work.



      Engine is LuaLaTeX.



      M(n-)WE:



      documentclass[11pt, a4paper]{book}
      usepackage[raggedright]{titlesec}
      usepackage{fontspec}

      newfontfamilypartfont{Verdana.ttf}
      titleformat*{part}{partfont}

      newfontfamilychapterfont{Verdana.ttf}
      titleformat*{chapter}{chapterfont}

      begin{document}
      part{Hello world.}
      chapter{Hello again, world.}
      end{document}






      fontspec titlesec books






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 20 at 11:32









      CraigCraig

      301112




      301112






















          1 Answer
          1






          active

          oldest

          votes


















          3














          The part command can't be changed using the “easy” mode. When you compile your code you get this error:



          ! Package titlesec Error: Not allowed in `easy' settings.

          See the titlesec package documentation for explanation.
          Type H <return> for immediate help.
          ...

          l.7 titleformat*{part}{partfont}

          ? h % < I typed h<return> here
          The sectiong command you are trying to redefine
          is not handled by the starred variant (eg, part)
          ?


          You'll have to use the general form of the titleformat macro (i.e. without the *) and replicate the part command from book class. Use this titleformat:



          titleformat{part}
          {filcenterhugebfseries} % Format of the section header
          {partnamenobreakspacethepart} % Format of the “Part X” text
          {0pt} % Horizontal space (none, we want vertical)
          {\vspace{20pt}Huge} % Commands before the title part (vertical space of 20 pt and increase in font size


          The chapter command allows you to use titleformat*, so your code works.



          Now you just have to add in your custom font. I used TeX Gyre Termes for I don't have Verdana.ttf:



          documentclass[11pt, a4paper]{book}
          usepackage[raggedright]{titlesec}
          usepackage{fontspec}

          newfontfamilypartfont{Tex Gyre Termes}
          titleformat{part}
          {filcenterhugebfseriespartfont}
          {partnamenobreakspacethepart}
          {0pt}
          {\vspace{20pt}Huge}

          titleformat{chapter}[display]
          {normalfonthugebfseries}{chaptertitlename thechapter}{20pt}{Huge}

          newfontfamilychapterfont{Tex Gyre Termes}
          titleformat*{chapter}{normalfonthugebfserieschapterfont}

          begin{document}
          part{Hello world.}
          chapter{Hello again, world.}
          end{document}


          Part heading:




          enter image description here




          Chapter heading:




          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',
            autoActivateHeartbeat: false,
            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%2f480462%2fchanging-typeface-of-part%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            3














            The part command can't be changed using the “easy” mode. When you compile your code you get this error:



            ! Package titlesec Error: Not allowed in `easy' settings.

            See the titlesec package documentation for explanation.
            Type H <return> for immediate help.
            ...

            l.7 titleformat*{part}{partfont}

            ? h % < I typed h<return> here
            The sectiong command you are trying to redefine
            is not handled by the starred variant (eg, part)
            ?


            You'll have to use the general form of the titleformat macro (i.e. without the *) and replicate the part command from book class. Use this titleformat:



            titleformat{part}
            {filcenterhugebfseries} % Format of the section header
            {partnamenobreakspacethepart} % Format of the “Part X” text
            {0pt} % Horizontal space (none, we want vertical)
            {\vspace{20pt}Huge} % Commands before the title part (vertical space of 20 pt and increase in font size


            The chapter command allows you to use titleformat*, so your code works.



            Now you just have to add in your custom font. I used TeX Gyre Termes for I don't have Verdana.ttf:



            documentclass[11pt, a4paper]{book}
            usepackage[raggedright]{titlesec}
            usepackage{fontspec}

            newfontfamilypartfont{Tex Gyre Termes}
            titleformat{part}
            {filcenterhugebfseriespartfont}
            {partnamenobreakspacethepart}
            {0pt}
            {\vspace{20pt}Huge}

            titleformat{chapter}[display]
            {normalfonthugebfseries}{chaptertitlename thechapter}{20pt}{Huge}

            newfontfamilychapterfont{Tex Gyre Termes}
            titleformat*{chapter}{normalfonthugebfserieschapterfont}

            begin{document}
            part{Hello world.}
            chapter{Hello again, world.}
            end{document}


            Part heading:




            enter image description here




            Chapter heading:




            enter image description here







            share|improve this answer




























              3














              The part command can't be changed using the “easy” mode. When you compile your code you get this error:



              ! Package titlesec Error: Not allowed in `easy' settings.

              See the titlesec package documentation for explanation.
              Type H <return> for immediate help.
              ...

              l.7 titleformat*{part}{partfont}

              ? h % < I typed h<return> here
              The sectiong command you are trying to redefine
              is not handled by the starred variant (eg, part)
              ?


              You'll have to use the general form of the titleformat macro (i.e. without the *) and replicate the part command from book class. Use this titleformat:



              titleformat{part}
              {filcenterhugebfseries} % Format of the section header
              {partnamenobreakspacethepart} % Format of the “Part X” text
              {0pt} % Horizontal space (none, we want vertical)
              {\vspace{20pt}Huge} % Commands before the title part (vertical space of 20 pt and increase in font size


              The chapter command allows you to use titleformat*, so your code works.



              Now you just have to add in your custom font. I used TeX Gyre Termes for I don't have Verdana.ttf:



              documentclass[11pt, a4paper]{book}
              usepackage[raggedright]{titlesec}
              usepackage{fontspec}

              newfontfamilypartfont{Tex Gyre Termes}
              titleformat{part}
              {filcenterhugebfseriespartfont}
              {partnamenobreakspacethepart}
              {0pt}
              {\vspace{20pt}Huge}

              titleformat{chapter}[display]
              {normalfonthugebfseries}{chaptertitlename thechapter}{20pt}{Huge}

              newfontfamilychapterfont{Tex Gyre Termes}
              titleformat*{chapter}{normalfonthugebfserieschapterfont}

              begin{document}
              part{Hello world.}
              chapter{Hello again, world.}
              end{document}


              Part heading:




              enter image description here




              Chapter heading:




              enter image description here







              share|improve this answer


























                3












                3








                3







                The part command can't be changed using the “easy” mode. When you compile your code you get this error:



                ! Package titlesec Error: Not allowed in `easy' settings.

                See the titlesec package documentation for explanation.
                Type H <return> for immediate help.
                ...

                l.7 titleformat*{part}{partfont}

                ? h % < I typed h<return> here
                The sectiong command you are trying to redefine
                is not handled by the starred variant (eg, part)
                ?


                You'll have to use the general form of the titleformat macro (i.e. without the *) and replicate the part command from book class. Use this titleformat:



                titleformat{part}
                {filcenterhugebfseries} % Format of the section header
                {partnamenobreakspacethepart} % Format of the “Part X” text
                {0pt} % Horizontal space (none, we want vertical)
                {\vspace{20pt}Huge} % Commands before the title part (vertical space of 20 pt and increase in font size


                The chapter command allows you to use titleformat*, so your code works.



                Now you just have to add in your custom font. I used TeX Gyre Termes for I don't have Verdana.ttf:



                documentclass[11pt, a4paper]{book}
                usepackage[raggedright]{titlesec}
                usepackage{fontspec}

                newfontfamilypartfont{Tex Gyre Termes}
                titleformat{part}
                {filcenterhugebfseriespartfont}
                {partnamenobreakspacethepart}
                {0pt}
                {\vspace{20pt}Huge}

                titleformat{chapter}[display]
                {normalfonthugebfseries}{chaptertitlename thechapter}{20pt}{Huge}

                newfontfamilychapterfont{Tex Gyre Termes}
                titleformat*{chapter}{normalfonthugebfserieschapterfont}

                begin{document}
                part{Hello world.}
                chapter{Hello again, world.}
                end{document}


                Part heading:




                enter image description here




                Chapter heading:




                enter image description here







                share|improve this answer













                The part command can't be changed using the “easy” mode. When you compile your code you get this error:



                ! Package titlesec Error: Not allowed in `easy' settings.

                See the titlesec package documentation for explanation.
                Type H <return> for immediate help.
                ...

                l.7 titleformat*{part}{partfont}

                ? h % < I typed h<return> here
                The sectiong command you are trying to redefine
                is not handled by the starred variant (eg, part)
                ?


                You'll have to use the general form of the titleformat macro (i.e. without the *) and replicate the part command from book class. Use this titleformat:



                titleformat{part}
                {filcenterhugebfseries} % Format of the section header
                {partnamenobreakspacethepart} % Format of the “Part X” text
                {0pt} % Horizontal space (none, we want vertical)
                {\vspace{20pt}Huge} % Commands before the title part (vertical space of 20 pt and increase in font size


                The chapter command allows you to use titleformat*, so your code works.



                Now you just have to add in your custom font. I used TeX Gyre Termes for I don't have Verdana.ttf:



                documentclass[11pt, a4paper]{book}
                usepackage[raggedright]{titlesec}
                usepackage{fontspec}

                newfontfamilypartfont{Tex Gyre Termes}
                titleformat{part}
                {filcenterhugebfseriespartfont}
                {partnamenobreakspacethepart}
                {0pt}
                {\vspace{20pt}Huge}

                titleformat{chapter}[display]
                {normalfonthugebfseries}{chaptertitlename thechapter}{20pt}{Huge}

                newfontfamilychapterfont{Tex Gyre Termes}
                titleformat*{chapter}{normalfonthugebfserieschapterfont}

                begin{document}
                part{Hello world.}
                chapter{Hello again, world.}
                end{document}


                Part heading:




                enter image description here




                Chapter heading:




                enter image description here








                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 20 at 12:04









                Phelype OleinikPhelype Oleinik

                24.6k54688




                24.6k54688






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f480462%2fchanging-typeface-of-part%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

                    Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

                    ComboBox Display Member on multiple fields

                    Is it possible to collect Nectar points via Trainline?