1

I'm trying to load draft mode as an option for my class. Overfull lines are highlighted, but unfortunately images are loaded normally (not just as frame). Can someone please tell me why?

Class file:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{thesis}[template] 

\RequirePackage{ifthen}
\RequirePackage{iflang}
\RequirePackage{kvoptions}
\SetupKeyvalOptions{%
    family=SBMT,%
    prefix=SBMT@%
}

% Declare class options         
\DeclareBoolOption[false]{draftmode}            
\ProcessKeyvalOptions*  

% if draft mode is enabled (true) pass option "draft" to class
\ifthenelse{\boolean{SBMT@draftmode}}{%
        \PassOptionsToClass{draft}{scrbook}
    }{}

\LoadClass[
    fontsize=12pt,              
    DIV=12,                           
    open=right,                 
    cleardoublepage=empty,      
    parskip=half-,                  
    headings=normal             
]{scrbook}
\usepackage{scrhack} 

% Basics
\RequirePackage[utf8]{inputenc}
\RequirePackage{pdfpages}
\RequirePackage{graphicx}

Document:

\RequirePackage{kvoptions-patch}    
\documentclass[     
    draftmode=true ,        
]{thesis}
\setlength\headheight{30pt} 

\begin{document}
\includegraphics[width=1.1\textwidth]{example-image-a}
\end{document}

1 Answer 1

1

This issue is that in your custom class you load scrbook with \LoadClass and pass the options there, but you load graphicx using \RequirePackage in your own class. This causes the package loading to be outside the scope of \LoadClass and therefore the option is not passed.

You can check this when you uncomment \RequirePackage{graphicx} (and \RequirePackage{pdfpages} as well, because that package loads graphicx internally) and put \usepackage{graphicx} in your document, then the draft option is respected.

A workaround is to pass the option to graphicx explicitly (and to other required packages) using \PassOptionsToPackage.

Code:

% if draft mode is enabled (true) pass option "draft" to class
\ifthenelse{\boolean{SBMT@draftmode}}{%
        \PassOptionsToClass{draft}{scrbook}
        \PassOptionsToPackage{draft}{graphicx}
    }{}
2
  • Thanks, I already thought that the graphicx package is responsible for that issue. Are there other limitations of the draft mode if I do not change my code?
    – joni
    Oct 12, 2020 at 17:21
  • @joni the pdfpages package also has a draft setting (to print an empty box instead of the included pdf). Microtype has a draft setting that disables the functionality of the package. So also for these two packages that you require you need separate \PassOptionsToPackage statements. The other packages that you require don't have a draft setting as far as I know.
    – Marijn
    Oct 12, 2020 at 20:05

You must log in to answer this question.

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