2

[For the following, I found an answer myself, but I didn't find the necessary extra step on any forums. Therefore, I shortly provide it in Q&A style.]

I have some custom formatting to tweak my biblatex settings that I want LyX to use (via \DeclareFieldFormat), but putting those in the Latex preamble (via Document->Settings->LaTeX Preamble) creates errors. (In my case, I want all titles to be Italic which makes using a footnote style and referring to titles and shorttitles within Text more legible.)

The problem seems that LyX loads biblatex just before \begin{document} as seen in exported LaTeX, but the custom LaTeX preamble before that. Tweaking biblatex before loading biblatex seems bad.

Errors are classic:

Undefined control sequence

Missing \begin{document}

You can't use `macro parameter character #' in horizontal mode. 

etc.

1 Answer 1

2

What works is »storing« the modifications in the preamble via (in my case)

\AtBeginDocument{%
\DeclareFieldFormat{shorthand}{\mkbibemph{#1}}
\DeclareFieldFormat{title}{\mkbibemph{#1}}
\DeclareFieldFormat{citetitle}{\mkbibemph{#1}}
}
4
  • 1
    Note that this is also what the LyX wiki suggests in point 5 of Using Biblatex with LyX 2.3.0 and newer in wiki.lyx.org/BibTeX/Biblatex
    – moewe
    Jan 19, 2019 at 18:51
  • Dangit - I didn't notice that under the heading of "transitioning from 2.2". My bad!
    – Paul Burgh
    Jan 19, 2019 at 21:06
  • 1
    I edited the LyX wiki to make the need for \AtBeginDocument more prominent.
    – moewe
    Jan 20, 2019 at 8:35
  • Looking at the edit by @moewe I am certain I wouldn't have missed the solution in the Wiki. So this question could be closed / removed if so desired.
    – Paul Burgh
    Jan 25, 2019 at 18:44

You must log in to answer this question.

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