1

I have a custom layout file that is attached to my document and used by Lyx. The file is in ~/.lyx/layouts.

This question tells how to add a line to the preamble via the menu:

\renewcommand\partname{Act}

I'd like to keep all of my formatting in the layout file if possible and avoid setting things in the Lyx menus.

So I added that line to the Preamble section of my layout file, and also tried

\renewcommand{\partname}{Experiment}

but it does not work. After re-configuring, restarting and re-rendering the PDF, the parts are still called "part".

Is there a way to make this change ("part" to "act") work from the layout file?

And is there a way to make the editor reflect this change from within the layout file, without changing the default definition of the book class (which my layout file extends).

My Lyx version is 2.2.3 on Linux.

Update: Maybe \renewcommand{\partname}{Act} is the wrong command, as it doesn't work if you put it in the LATEX preamble section in Lyx document settings either.

Update two: here's a striped down layout file:

#  \DeclareLaTeXClass[book]{book (My Book Style)}

# Input general definitions
Input stdclass.inc


MaxCounter              Counter_Section
SecNumDepth             3


Preamble

% Tell the TOC not to include any levels below "chapter"
\setcounter{tocdepth}{0}

% Change "Part" to "Act"
\AtBeginDocument{\renewcommand{\partname}{Act}}
EndPreamble
6
  • Maybe try \AtBeginDocument{\renewcommand{\partname}{Experiment}}?
    – Bernard
    Mar 2, 2019 at 21:26
  • @Bernard: that didn't work.
    – Nick
    Mar 2, 2019 at 21:39
  • @Nick I would separate the problem to figure out whether the problem is with the LyX layout definition or with the LaTeX. Thus, first I would try to make a minimal LaTeX example and make sure it does what you want. Then the question is how to get the layout to produce that LaTeX.
    – scottkosty
    Mar 2, 2019 at 21:41
  • Hi @scottkosty: I just tried placing the line in LATEX preamble section of "document settings" via the Lyx menu and it did not work there either.
    – Nick
    Mar 2, 2019 at 21:43
  • 1
    Could you post a minimal code that reproduces the problem?
    – Bernard
    Mar 2, 2019 at 21:46

1 Answer 1

1

I believe the problem comes from babel, as it is redefining \partname every time it issues \setlanguage{<lang>} (in the begining of the document for example), see the question over here.

As suggested in that post, we need to use \addto\extrasenglish{\renewcommand{\partname}{Act}} instead of \renewcommand{\partname}{Act}. The problem is that lyx loads babel at the end of the preamble, so to add \addto\extrasenglish{\renewcommand{\partname}{Act}} the layout key "Preanble" wont work because the command will expand before it will be defined.

For that lyx has the "LangPreamble" key for paragraph layouts (see section 5.3.8 in lyx's customization guide). You cant use this key directly in layout class file, but only in the definition of a pargraph layout, hence we will redefine Part layout, to be exactly as in stdclass.inc but with the LangPreamble we want.

#  \DeclareLaTeXClass[book]{book (My Book Style)}

# Input general definitions
Input stdclass.inc

Style Part
    Category              Sectioning
    Margin                Dynamic
    LabelString           "Part \thepart"
    LabelType             Static
    TocLevel              -1
    LabelCounter          part
    LatexType             Command
    LatexName             part
    NeedProtect           1
    NextNoIndent          1
    ToggleIndent          Never
    Labelsep              xxx
    ParSkip               0.4
    TopSep                4
    BottomSep             4
    ParSep                0.8
    Align                 Center
    Alignpossible         Center
    Argument 1
        LabelString   "Short Title|S"
        Tooltip       "The part as it appears in the table of contents/running headers"
        InsertCotext  1
        IsTocCaption  1
    EndArgument
    Font
       Series              Bold
       Size                Huge
    EndFont
    HTMLTag               h1
    LangPreamble
    \addto\captionsenglish{\renewcommand{\partname}{Act}}
    EndLangPreamble
 End


MaxCounter              Counter_Section
SecNumDepth             3


Preamble

% Tell the TOC not to include any levels below "chapter"
\setcounter{tocdepth}{0}
EndPreamble

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .