Redefining “ClearDoublePage” ruins subfigures

I found some solution to add a "This page intentionally left blank" text on clear pages by redefining things in preamble, but it somehow messes up with subfloats. If I have a subfigure / subtable, when trying to View the document there are errors:

You can't use \spacefactor' in vertical mode.
Missing \$ inserted.
LaTeX Error: Missing \begin{document}.
Missing glyphs!
Use of \sf doesn't match its definition.
...


and more.

I am using a KOMA-Script Book document class, and the preamble looks like this:

\newcommand*{\blankpage}{%
\par\vspace*{0.25\textheight}%
{\centering \emph{This page intentionally left blank.}\par}
\vspace{\fill}%
}
\makeatletter
\renewcommand*{\cleardoubleoddstandardpage}{%
\clearpage
\if@twoside
\ifodd\c@page
\else
\blankpage
\thispagestyle{empty}%
\newpage
\if@twocolumn\hbox{}\newpage\fi
\fi
\fi
}
\makeatother


The LyX document file available here.
System configuration:
LyX Version 2.2.3
Windows 10 x64
MiKTeX 2.9

• Welcome to TeX.SX! Please include your minimal working example (MWE), to your question and avoid links (which could be broken in the future). Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass and ending with \end{document}. – Bobyandbob Jul 14 '18 at 10:23
• You are using a KOMA-Script class. So maybe the following helps: tex.stackexchange.com/a/205545 – esdd Jul 14 '18 at 11:16

1 Answer

Indeed, esdd's sugestion worked.

After deleting this part

\renewcommand*{\cleardoubleoddstandardpage}{%
\clearpage
\if@twoside
\ifodd\c@page
\else
\blankpage
\thispagestyle{empty}%
\newpage
\if@twocolumn\hbox{}\newpage\fi
\fi
\fi
}
\makeatother
`

the document will compile.