1

I'm assembling a thesis by pasting articles into an old template. Template contains includes many packages, and when I try to include amsthm I get error that \openbox is already defined.

I was trying to be smart an debug it by moving amsthm import to the top of the file so that the package with the other \openbox definition breaks, but that causes Tex to run out of stack.

So the question to the community is, which packages other than amsthm define \openbox?

Here is the whole preamble

    %----------------------------------------------------------------------------------
% (c) 2018 Hennadii Madan, using as a template a thesis 
% (c) 2006,2007 Tomaz Vrtovec
% PhD Thesis
%----------------------------------------------------------------------------------

%--------------------------
% define document style: A4 paper size, two-sided printing, 12pt font, report style
\documentclass[a4paper,twoside,12pt]{report}
%--------------------------
% WARN ABOUT OBSOLETE PACKAGES (Oh, latex)
\usepackage{nag}
%--------------------------
% declare common packages
\usepackage[slovene,british]{babel}
\usepackage[utf8]{inputenc} %It is necessary to do the import with utf8 beacuse
 \inputencoding{cp1250}     %of the way inputenc works: for unicode but not
                            %other encodings is scans the files for the
                            %characters that are actually used and applies the
                            %settings only for them. So I import with utf8 but
                            %then immediately switch to cp1250 for the code
                            %written by Tomaz.

\usepackage[pdftex]{graphicx}
%\usepackage[pdftex,draft]{graphicx}        %remove draft for images!!!!
\usepackage{verbatim}
\usepackage{eso-pic}
% \usepackage{color}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{enumitem}
\usepackage{dsfont}
\usepackage{multirow}
\usepackage{txfonts}

% page dimensions (A4 = 8.5in x 11.0in)
\setlength{\textwidth}{6.3in}                       % width of text area (=  8.5in - 2*1.1in)
\setlength{\textheight}{9.0in}                  % height of text area (= 11.0in - 2*1.0in)
\setlength{\topmargin}{0.0in}                       % for top margin of 1.0in
\setlength{\headheight}{0.7in}                  % height of the head area
\setlength{\headsep}{0.5in}                         % separationbetween text and header
\setlength{\voffset}{-1.0in}                        % vertical offset
\setlength{\footskip}{1.0in}                        % baseline-baseline distance between footline and last line of text
\setlength{\oddsidemargin}{0.2in}               % side margin on odd pages
\setlength{\evensidemargin}{-0.1in}         % side margin on even pages
\raggedbottom                                                   % no extra vertical space is added to pages
% paragraph settings
\setlength{\parindent}{0.0in}                       % indentation of paragraphs
\setlength{\parskip}{0.0em}                         % set vertical space between paragraphs

%?? hyphenation settings
%\hyphenpenalty=5000
%\tolerance=1000

% disable overfull \hbox warnings ?? (\sloppy vs. \fussy)
\sloppy

% fonts (packages: mathdesign, concrete, mathpazo or none for cm default font)
%\usepackage[garamond]{mathdesign}  % font: Garamond + Mathdesign = OK (but without \textsc) 
%\usepackage[utopia]{mathdesign}        % font: Utopia + MathDesign math = OK (but without \textsc)
%\usepackage{bookman}                               % font: Bookman + default math = OK (but math doesn't really fit)
%\usepackage{concrete}                          % font: Concrete + Euler VM = OK (a little weird but nice math)
%\usepackage{mathpazo}                          % font: Palatino + Palatino Math = OK (very nice)
% large math symbols with some fonts (package: exscale): e.g. mathmazo
\usepackage{exscale}

% line numbers (package: lineno)
%\usepackage[switch,pagewise]{lineno}
    %\linenumbers       % turn on line numbering

% quotes above chapters (package: epigraph)
\usepackage{epigraph}
    \setlength{\epigraphrule}{0.0pt}                            % width of the epigraph rule
    \renewcommand{\epigraphsize}{\footnotesize}     % set epigraph font

% line spacing (package: setspace)
\usepackage{setspace}
  %\newcommand{\defaultspace}{1.28} % default space (35 line per page) for default font, mathpazo font
  \newcommand{\defaultspace}{1.1}
    \setstretch{\defaultspace}              % redefine spacing between lines (so there are 35 lines per page)

% put "." behind chapter section numbers
%\renewcommand \thechapter{\arabic{chapter}.}
%\renewcommand \thesection{\arabic{section}.}
%\renewcommand \thesubsection{\arabic{section}.\arabic{subsection}.}
%\renewcommand \thesubsubsection{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}.}

%fancy chapters (package: fncychap)
%\usepackage[Sonny_mod]{./styles/fncychap_mod}
\usepackage[Sonny]{fncychap}
  \ChRuleWidth{1.0pt}
    \ChNameVar{\rm\LARGE\flushleft}
    \ChNumVar{\rm\huge}
    \ChTitleVar{\rm\bfseries\Huge\flushleft}

% fancy headers and footers (package: fancyhdr)
\usepackage{fancyhdr}
    \pagestyle{fancy}  
    % running title as ''1 - Title'', plus font as \footnotesize
  \renewcommand{\chaptermark}[1]{\markboth{\footnotesize\thechapter{\,-\,}#1}{}}
  % running title as ''Chapter 1. Title'', plus font as \footnotesize
  %\renewcommand{\chaptermark}[1]{\markboth{\footnotesize \chaptername\ \thechapter\ {~-~} #1}{}}
  \fancyhf{}
  \fancyhead[LE,RO]{\footnotesize \thepage}
    \fancyhead[RE,LO]{\footnotesize \nouppercase{\leftmark}}
  \renewcommand{\headrulewidth}{0.4 pt}
  \renewcommand{\footrulewidth}{0.0 pt}
    % creating empty pages: no headers on empty pages before new chapter
  \makeatletter
  \renewcommand{\cleardoublepage}{\clearpage\if@twoside \ifodd\c@page\else
     \thispagestyle{empty}
     \hbox{}\newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi}
  \makeatother

% hyperlinks (package: hyperref)
\usepackage[plainpages=false,unicode=true,hyperfootnotes,hyperindex,pagebackref,backref=page]{hyperref}
  % define pdf document properties
    \hypersetup{
    %colorlinks=true,                                   %set 'true' for web version
    colorlinks=false,pdfborder=0,       %set 'false' for print version
    linkcolor=red,anchorcolor=red,citecolor=blue,filecolor=cyan,
    pagecolor=green,urlcolor=red,
    %bookmarksopen=false,bookmarksnumbered=false,
    %pdfpagemode=FullScreen,
    %pdfpagemode=UseOutlines,
    pdftitle={Error estimation in quantitative image analysis},
    pdfauthor={Hennadii Madan},
    pdfsubject={PhD thesis (University of Ljubljana, Faculty of Electrical Engineering, Slovenia)},     
    pdfkeywords={medical image analysis, medical image processing, bayeasian, statisitcs},
    baseurl={http://lit.fe.uni-lj.si},
    pdfview={Fit},
    pdfstartpage={1},
    pdfstartview={Fit}
    %??keywords
    }
    % back reference citations ("cited on page X")
    \renewcommand*{\backref}[1]{}
    \renewcommand*{\backrefalt}[4]{
        \ifcase #1
            (not cited)
        \or
            (cited on page~#2)
        \else
            (cited on pages~#2)
        \fi}
    \renewcommand*{\backrefsep}{, }
    \renewcommand*{\backreftwosep}{ and~}
    \renewcommand*{\backreflastsep}{ and~}

% footnotes (packages: fnpos, dblfnote, fnbreak)
\usepackage{fnpos}
    \makeFNbottom                                                           % footnotes at the bottom of the page
    \makeFNbelow                                                            % footnotes places below the last floats on the page
\usepackage{dblfnote}
  \DFNcolumnsep 1.5\columnsep                               % set the distance between footnote columns
  %\DFNtrysingle                                                      % try to set footnotes in one column
  \DFNalwaysdouble                                                  % always set footnotes in two columns
    \makeatletter                                                           % set space between text and footnote (1em = one line)
    \renewcommand\footnoterule{
        \vspace{1.5em}
        \kern-3\p@\hrule\@width.4\columnwidth   
    \kern2.6\p@}
    \makeatother  
    %\interfootnotelinepenalty=10000                    % prevent footnotes to be placed on two pages   or columns
    \interfootnotelinepenalty=5000                      % footnotes most likely will not be placed on two pages or columns
% define the unnumbered footnote command (use \symbolfootnote[0]{footnote})
\long\def\symbolfootnote[#1]#2{\begingroup\def\thefootnote{\fnsymbol{footnote}}\footnote[#1]{#2}\endgroup} 
% displays warning if footnotes are split across pages
\usepackage{fnbreak}

% add stared chapters to toc (package: tocbibind): bibliography and index
\usepackage[chapter,nottoc,notlot,notlof]{tocbibind}

% table of contents (package: tocloft), option 'titles' for typesetting titles like in 'fncychap'
\usepackage[titles,subfigure]{tocloft}
  \renewcommand{\cftchapleader}{\bfseries\cftdotfill{\cftsubsecdotsep}}     % bold dots follow chapteras in subsection
    \renewcommand{\cftsecleader}{\bfseries\cftdotfill{\cftsubsecdotsep}}        % bold dots follow section as in subsection
    %\setlength{\cftaftertoctitleskip}{1.0cm}                                                               % space after toc title
    \renewcommand{\cftchapfont}{\large\bfseries}                                                        % change chapter title font
    \setlength{\cftbeforechapskip}{0.5cm}                                                                       % space between chapters
    \setlength{\cftbeforesecskip}{0.25cm}                                                                       % space between sections
    \setlength{\cftbeforesubsecskip}{0.05cm}                                                                % space between subsections

% index (package: makeidx)
%\usepackage{makeidx}
    %\makeindex
% text in multiple columns (package: multicol): to print such index
\usepackage{multicol}
% format index (package: doc): set index chapter and add it to toc [modified style to set index epigraph]
%\usepackage{./styles/doc_mod}
    %\IndexPrologue{\chapter*{Index}\markboth{Index}{Index}\addcontentsline{toc}{chapter}{\protect{Index}}} 

% abbreviations {package: acronym}
\usepackage[printonlyused]{acronym} 

% glossary (package: glossary) [modified style in order to modify the glossary header]
%\usepackage[style=altlist,acronym=true,section=false,number=page,toc=true,hyper=true,cols=2]{./styles/glossary_mod}
    % order to make the glossary 
    %\makeglossary
    % order to make the acronyms
    %\makeacronym
    %!! glossary package does not work with acronym package, but do not need them anyway cos I have footnotes

% wrap text around floats (package: floatflt)
\usepackage{floatflt}

% break tabular across pages (package: supertabular)
\usepackage{supertabular}

% float captions (package: caption)
\usepackage[labelsep=period, labelfont={small,bf}, textfont=small,
tableposition=below,
% aboveskip=-0.3cm, % no idea why Tomaz had it, it causes
                     %captions to overlap the graphical data
                        belowskip=0.5cm, width=0.9\textwidth]{caption}
    \renewcommand{\thefigure}{\thechapter.\arabic{figure}}
    \renewcommand{\thetable}{\thechapter.\arabic{table}}
    \renewcommand{\theequation}{\thechapter.\arabic{equation}}
%% THIS NO LONGER WORKS! BECAUSE https://tex.stackexchange.com/a/139509/88195
  % subfigures (package: subfigure) [modified, so counters are not re-defined]
  % \usepackage[loose]{./styles/subfigure_mod}  
%% SUBCAPTION (E.G.) IS TO BE USED INSTEAD (see HENNADII!!! comment below)

% bibliography (package: natbib) [modified style in order to include epigraph in bibliography]
\usepackage[round,comma,sort&compress,nonamebreak]{./styles/natbib_mod}
  \setlength{\bibsep}{0.25cm}                                                                               % set the bibliography line spacing

% landscape oriented pages (package: lscape)
\usepackage{lscape}

% date and time formatting (package: datetime)  
\usepackage{datetime}
    %\newcommand{\reviewtime}{\vspace{-0.5cm} \large \textit{~\\~\\DRAFT VERSION:~{\today}~@~{\currenttime}\\}} % 'DRAFT VERSION: date @ time'
    \newcommand{\reviewtime}{Ljubljana, 2018}

% dropped captials (package: lettrine)
\usepackage{lettrine}
    \setcounter{DefaultLines}{2}
    %\renewcommand{\DefaultLoversize}{0.8}
    %\renewcommand{\LettrineTextFont}{\scshape}

% floating figures and wrapped text around them (package: floatflt)
\usepackage{floatflt}
\usepackage{color,soul}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{cleveref}



% USER-DEFINED COMMANDS
% single reference, parenthesis version
\newcommand{\srefp}[2]
    {\ifthenelse{\equal{#1}{figure} \OR \equal{#1}{table} \OR \equal{#1}{equation}}
    {(#1~\ref{#2}, p.~\pageref{#2})}
    {(#1~\ref{#2}, str.~\pageref{#2})}}
% single reference, text version
\newcommand{\sreft}[2]
    {\ifthenelse{\equal{#1}{figure} \OR \equal{#1}{table} \OR \equal{#1}{equation} \OR \equal{#1}{Figure} \OR 
     \equal{#1}{Table} \OR \equal{#1}{Equation}}
    {#1~\ref{#2} (p.~\pageref{#2})}
    {#1~\ref{#2} (str.~\pageref{#2})}}
% double reference, parenthesis version
\newcommand{\drefp}[3]
    {\ifthenelse{\equal{#1}{figures} \OR \equal{#1}{tables} \OR \equal{#1}{equations}}
    {(#1~\ref{#2}, p.~\pageref{#2} and~\ref{#3}, p.~\pageref{#3})}
    {(#1~\ref{#2}, str.~\pageref{#2} in~\ref{#3}, str.~\pageref{#3})}}
% double reference, text version
\newcommand{\dreft}[3]
    {\ifthenelse{\equal{#1}{figures} \OR \equal{#1}{tables} \OR \equal{#1}{equations} \OR \equal{#1}{Figures} \OR 
     \equal{#1}{Tables} \OR \equal{#1}{Equations}}
    {#1~\ref{#2} (p.~\pageref{#2}) and~\ref{#3} (p.~\pageref{#3})}
    {#1~\ref{#2} (str.~\pageref{#2}) in~\ref{#3} (str.~\pageref{#3})}}

% the caption in the 2nd language
\newcommand{\othercaption}[2]   
    {\ifthenelse{\equal{#1}{figure}}
    {\addtocounter{figure}{1}\ContinuedFloat\parbox[c]{0.9\textwidth}{\small \textbf{Slika \thefigure.}~#2}}
    {\addtocounter{table}{1}\ContinuedFloat\parbox[c]{0.9\textwidth}{\small \textbf{Tabela \thetable.}~#2}}}

% paragraph with the dropped capital (lettrine)
\newcommand{\parlet}[3]
    %{\fontfamily{ptm} \lettrine{#1}{#2} #3 \fontfamily{cmr}}
    {\lettrine{#1}{#2} #3}

% define table rules (normal and big)
\newcommand{\tablerule}{\rule{0pt}{2ex}}
\newcommand{\Tablerule}{\rule{0pt}{3ex}}
%-------------------------
%%>>>>>>>>>>>>>>> HENNADII!!! <<<<<<<<<<<<<<<
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}
\usepackage{xspace}
\usepackage{siunitx}
\usepackage{mathtools}
\usepackage{gensymb}
\usepackage{bm}


\usepackage{subcaption} %for a,b,c,d in figures
\captionsetup{subrefformat=parens}

% MAKE MATLAB/MPL2TIKZ WORK:
%% MATLAB 2 TIKZ PREAMBLE
\usepackage{tikz}
% \usetikzlibrary{external}
% \tikzset{external/system call={pdflatex \tikzexternalcheckshellescape 
%                                         -halt-on-error
%                                         -interaction=batchmode 
%                                         -jobname "\image" "\texsource"
%                                         && pdftops -eps "\image.pdf"}}
% \tikzexternalize[shell escape=-enable-write18]
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
  %% the following commands are sometimes needed
  \usetikzlibrary{plotmarks}
  \usepackage{grffile}
  %% you may also want the following commands
  %\pgfplotsset{plot coordinates/math parser=false}
  \newlength\figureheight
  \newlength\figurewidth

%% ACRONYMS
\usepackage[acronym]{glossaries}
% \makeglossaries

%>>>>>>>>>>>>>>> FOR CHAPTER 2 (AUTO_GS_ARTICLE)
\newacronym{32R}{32R}{3D/2D image registration}
\newacronym{23R}{32R}{3D/2D image registration}
\newacronym{R32R}{R32R}{rigid 3D/2D image registration}
% Despite Franjo's notes 23R is used somewhat more frequently used than 32R
\newacronym{IB23R}{IB23R}{image-based 3D/2D image registration}
\newacronym{IB32R}{IB32R}{image-based 3D/2D image registration}
% \newacronym{RWT}{RWT}{regression without truth}
\newacronym{SR}{SR}{success rate}
\newacronym{TRE}{TRE}{target registration error}
\newacronym{mTRE}{mTRE}{mean target registration error}
\newacronym{FRE}{FRE}{fiducial registration error}
\newacronym{FLE}{FLE}{fiducial localization error}
\newacronym{mPD}{mPD}{mean projection distance}
\newacronym{OR}{OR}{operating room}
\newacronym{IGI}{IGI}{image-guided interventions} 
\newacronym{IGRT}{IGRT}{image-guided radiation therapy} 
\newacronym{SM}{SM}{similarity measure}
\newacronym{GSC}{GSC}{gold standard creation}
\newacronym{DM}{DM}{detected markers} 
\newacronym{PM}{PM}{detected markers} 
\newacronym{AVM}{AVM}{arteriovenous malformation}
\newacronym{3D-DSA}{3D-DSA}{3D digital subtraction angiogram}
\newacronym{DSA}{DSA}{digital subtraction angiogram}
\newacronym{2D-DSA}{2D-DSA}{2D digital subtraction angiogram}
\newacronym{XA}{XA}{X-ray angiography}
\newacronym{CBCT}{CBCT}{cone-beam computed tomogram}
\newacronym{CT}{CT}{computed tomography}
\newacronym{MR}{MR}{magnetic resonance}
\newacronym{3D}{3D}{three-dimensional}
\newacronym{2D}{2D}{two-dimensional}
\newacronym{DRR}{DRR}{digitally reconstructed radiograph}
\newacronym{AHC}{AHC}{agglomerative hierarchical clustering}
\newacronym[firstplural=regions of interest (ROIs)]{ROI}{ROI}{region of interest}
\newacronym[firstplural=volumes of interest (VOIs)]{VOI}{VOI}{volume of interest}
\newacronym{rms}{rms}{root mean squared}
\newacronym{SVD}{SVD}{singular value decomposition}
\newacronym{WHO}{WHO}{World Health Organization}
\newacronym{dof}{DoF}{degrees of freedom}
\newacronym{SOD}{SOD}{source to object distance}
\newacronym{SID}{SID}{source to detector distance}
\newacronym{PA}{PA}{primary angle}
\newacronym{SA}{SA}{secondary angle}
\newacronym{WP}{WP}{working projection}
\newacronym{OP}{OP}{orthogonal to the working projection}

%>>>>>>>>>>>>>>> FOR CHAPTER 3 (ARTICLE_REFFREE_REGRESSION)
\newacronym{rmse}{RMSE}{root mean square error}
\newacronym{mcmc}{MCMC}{Markov chain Monte-Carlo}
\newacronym{ef}{EF}{left-ventricular ejection fraction}
\newacronym{qib}{QIB}{quantitative imaging biomarker}
\newacronym{qiba}{QIBA}{quantitative imaging biomarker alliance}
\newacronym{mle}{MLE}{maximum likelihood estimate}
\newacronym{map}{MAP}{maximum a posteriori}
\newacronym{mri}{MRI}{magnetic resonance image}
\newacronym{ms}{MS}{multiple sclerosis}
\newacronym{tll}{TLL}{total lesion load}
\newacronym{ct}{CT}{computed tomography}
\newacronym{cns}{CNS}{central neural system}
\newacronym{ls}{LS}{least squares}
\newacronym{mvg}{MVG}{multivariate Gaussian}
\newacronym{umcl}{UMCL}{University Medical Centre Ljubljana}
\newacronym{iprg}{IPRG}{Interdisciplinary Pharmacogenomics Review Group}
% \newacronym{cod}{COD}{coefficient of determination}


%>>>>>>>>>>>>>>> FOR CHAPTER 4 (PRACTICAL PRIORS)
\newacronym{csf}{CSF}{cerebrospinal fluid}
\newacronym{cr}{CR}{credible region}
\newacronym{ci}{CI}{credible interval}
\newacronym{nuts}{NUTS}{No U-Turn Sampler}
\newacronym{rwt}{RWT}{regression without truth}
\newacronym{lkj}{LKJ}{Lewandowski Kurowicka Joe}
\newacronym{std}{STD}{standard deviation}
% \newacronym{rmse}{RMSE}{root mean square error}
% \newacronym{mcmc}{MCMC}{Markov chain Monte-Carlo}
% \newacronym{ef}{EF}{left-ventricular ejection fraction}
% \newacronym{qib}{QIB}{quantitative imaging biomarker}
% \newacronym{qiba}{QIBA}{quantitative imaging biomarker alliance}
% \newacronym{mle}{MLE}{maximum likelihood estimate}
% \newacronym{map}{MAP}{maximum a posteriori}
% \newacronym{mri}{MRI}{magnetic resonance image}
\newacronym{mr}{MR}{magnetic resonance}
% \newacronym{ms}{MS}{multiple sclerosis}
% \newacronym{tll}{TLL}{total lesion load}
% \newacronym{ct}{CT}{computed tomography}
% \newacronym{cns}{CNS}{central neural system}
% \newacronym{ls}{LS}{least squares}
% \newacronym{mvg}{MVG}{multivariate Gaussian}
% \newacronym{umcl}{UMCL}{University Medical Centre Ljubljana}
\newacronym{umcm}{UMCM}{University Medical Centre Maribor}
% \newacronym{iprg}{IPRG}{Interdisciplinary Pharmacogenomics Review Group}
% \newacronym{cod}{COD}{coefficient of determination}
\newacronym{mm}{MM}{measurement method}
\newcommand{\mm}{\glspl{mm}}
\newacronym{gs}{GS}{gold standard}
\newcommand{\gs}{\gls{gs}}
\newacronym{wm}{WM}{white matter}
\newacronym{gm}{GM}{grey matter}
\newacronym{mae}{MAE}{mean absolute error}



%% END ACRONYMS
%% MY WHIMS
\newcommand{\noun}[1]{\textit{#1}}% Original formatting of nouns
\DeclareMathOperator*{\argmin}{\arg\!\min}
\DeclareMathOperator*{\argmax}{\arg\!\max}
% shortcuts to save typing
% \newcommand{\gs}{gold standard\xspace} 
\newcommand{\Gs}{Gold standard\xspace} 
\newcommand{\IGI}{\gls{IGI} }
\newcommand{\IGRT}{\gls{IGRT} }
%%>>>>>>>>>>>>>>> END HENNADII!!! <<<<<<<<<<<<<<<

%--------------------------
% BEGIN DOCUMENT

EDIT: This question was marked as duplicate of this, but I dare to think that it is somewhat different. In my case the offending package was txfonts while in the other question it is newtxmath. The answer to my question would ideally be the list of all packages defining openbox. -----**

0
2

Quick workaround: Load txfonts after amsthm

\documentclass[a4paper,twoside,12pt]{report}

\usepackage{amsthm}
\usepackage{txfonts}

\begin{document}
test
\end{document}
1

Not the answer you're looking for? Browse other questions tagged or ask your own question.