Dear Jürgen,

thanks for the quick feedback.

It seems like the incompatibility occurred in one of the updates of units or 
siunitx - before updating to the newest versions they could coexist.

Furthermore, nicefrac was used and thus units was required.

Your solution works fine! My document is now fully based on siunitx.

Kind regards,
Julian

#solution

Am Montag, dem 20.03.2023 um 12:51 +0000 schrieb Julian Popp:
> Dear LyX users,
> 
> I came across an (for me) unexpected behavior in LyX 2.3 that
> probably requires me to change my whole document...
> 
> For typesetting units and values correctly, I used the package
> siunitx. Since I got a new notebook and now have LyX 2.3.7 (+MiTeX)
> instead of 2.3.5-1 (in addition to package updates) there is now an
> error about the incompatibility of the packages units and siunitx.
> The issue here is: I do not have the \usepackage{units} in my custom
> document preamble.
> 
> After some investigation I found out that LyX in nevertheless
> including the \usepackage{units}  in the LaTeX code (export -> LaTeX
> (pdflatex)). See code below.

LyX autoloads the package if you use a construct that requires this
package (e.g., \unitfrac, \unitfracthree, \nicefrac).

> Has anybody else experienced that issue? Recommendations for
> mitigation?

You can prevent autoloading by entering to Document > Settings > Local
Layout:

Provides units 1

But if you now have a LaTeX macro which requires this package (and is
not covered by siunitx), you'll get an "undefined control sequence"
error.

HTH,
Jürgen


-----Original Message-----
From: Popp, Julian (EEI) 
Sent: Monday, March 20, 2023 13:51
To: 'lyx-users@lists.lyx.org' <lyx-users@lists.lyx.org>
Subject: Default usepackage units (LyX Default?) and user-specific siunitx

Dear LyX users,

I came across an (for me) unexpected behavior in LyX 2.3 that probably requires 
me to change my whole document.

For typesetting units and values correctly, I used the package siunitx. Since I 
got a new notebook and now have LyX 2.3.7 (+MiTeX) instead of 2.3.5-1 (in 
addition to package updates) there is now an error about the incompatibility of 
the packages units and siunitx. The issue here is: I do not have the 
\usepackage{units} in my custom document preamble.

After some investigation I found out that LyX in nevertheless including the 
\usepackage{units}  in the LaTeX code (export -> LaTeX (pdflatex)). See code 
below.

Has anybody else experienced that issue? Recommendations for mitigation?

BTW: uninstalling the package from MikTeX and removing the "units" entries in 
.sty files in the LyX folder does not work :)

Thanks,
Julian

###############################
### For Reference - User specific LaTeX Preamble:
\usepackage{url}
\usepackage{breakurl}

% Package for correct format of number and unit \usepackage{siunitx}

% COlor Package for use with ANS.1 definition \usepackage{xcolor}


%%%
% [.] removed formatting commands
%%

%Set Path for graphics
\graphicspath{pics}

% TikZ Package for R graphics
%\usepackage{tikz} 

\usepackage{asn1}
\lstdefinelanguage{ASN1}
{
morekeywords=[1]{DEFINITIONS,AUTOMATIC,TAGS,BEGIN,END,%
SEQUENCE,OF,CHOICE,ENUMERATED,NULL,SIZE,OPTIONAL,%
OCTET,BIT,STRING,INTEGER,REAL,BOOLEAN,WITH,COMPONENTS},%
commentstyle=\itshape,%
morecomment=[l][\color{gray}]{--},%
morecomment=[n]{/*}{*/}
}

% Front part of the book
\frontmatter


#############################
### For Reference - the LaTeX export code:
\documentclass[a4paper,english,DIV=13,BCOR=10mm,toc=flat,listof=totoc]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\setcounter{tocdepth}{1}
\usepackage{babel}
\usepackage{units}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{nomencl}
% the following is useful when we have the old nomencl.sty package 
\providecommand{\printnomenclature}{\printglossary}
\providecommand{\makenomenclature}{\makeglossary}
\makenomenclature
\usepackage[unicode=true,
 bookmarks=true,bookmarksnumbered=true,bookmarksopen=true,bookmarksopenlevel=2,
 breaklinks=false,pdfborder={0 0 
0},pdfborderstyle={},backref=false,colorlinks=false]
 {hyperref}
\hypersetup{pdftitle={ },
 pdfauthor={ },
 pdfsubject={ },
 pdfkeywords={}
}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\pdfpageheight\paperheight
\pdfpagewidth\paperwidth

%% Because html converters don't know tabularnewline 
\providecommand{\tabularnewline}{\\}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\newenvironment{lyxcode}
        {\par\begin{list}{}{
                \setlength{\rightmargin}{\leftmargin}
                \setlength{\listparindent}{0pt}% needed for AMS classes
                \raggedright
                \setlength{\itemsep}{0pt}
                \setlength{\parsep}{0pt}
                \normalfont\ttfamily}%
         \item[]}
        {\end{list}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{url}
\usepackage{breakurl }
 --> Continue with the custom preamble
-- 
lyx-users mailing list
lyx-users@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-users

Reply via email to