0

I configured my document in chapters that are self compilable. Each chapter is configured like this:

\documentclass[crop=false,class=embedchap]{standalone}
\begin{document}
    \begin{subappendices}
        \input{merge-algo}
    \end{subappendices}
\end{document}

With the following embedchap.cls:

% embedchap
% This package provides common settings for chapters embedded in the book
%
% When a chapter is compiled by itself is compiled as an article

\NeedsTeXFormat{LaTeX2e} \ProvidesClass{embedchap}[2019/09/01 Common configurations for the chapters embedded in the book]

% This class is based on KOMA script article class \LoadClass{scrartcl}

% We want the title as in an article, instead of a book \KOMAoptions{titlepage=false,fontsize=12pt}

% :: Language and charset \RequirePackage[utf8]{inputenc} \RequirePackage[french,american]{babel} \RequirePackage[T1]{fontenc}

\RequirePackage{standalone}

\RequirePackage{appendix}

\RequirePackage{algorithm} \RequirePackage{algpseudocode}

Now, if the content of merge-algo.tex is the following:

\section{Algorithm to handle multiblock simulations}
\begin{algorithm}
    \caption{Algorithm to merge a multi-block  simulation}
    \label{algo:merge}
    \begin{algorithmic}[1]
        \Procedure{MergeBlocks}{$blocks$}
            \State $blocks\gets$\Call{Sort}{$blocks$}
            \State $b_0 \gets blocks[0]$
            \State $n_x, n_y, n_z \gets$ \Call{GetDimensions}{$b_0$}\Comment{Get first block dimensions}
            \State $b_0\rightarrow$ \Call{SetStartIJK}{$0, 0, 0$}\Comment{The starting $i, j, k$ indices in the merged block}
        \EndProcedure
    \end{algorithmic}
\end{algorithm}

when I compile the individual chapter, I get the following error:

! Extra }, or forgotten \endgroup.
\@endfloatbox ...pagefalse \outer@nobreak \egroup
                                                  \color@endbox
l.13 \end{algorithm}

Any help on how to solve?

rdbisme
  • 211
  • Standalone doesn't normally support floats of any kind, like algorithm. I take it you are trying to put an entire chapter onto one page? – John Kormylo Jan 06 '21 at 03:34
  • What I'm doing is compiling an individual chapter, that normally is included in the main.tex file of the book with the others, independently, as a KOMA script article. Everything works as expected, including figure floats, but it does not work if I use subappendices. If I remove the subappendices environment, it also works as expected. – rdbisme Jan 06 '21 at 19:57
  • You don't need to use standalone to compile chapters separately. \include and \includeonly do a better job, particularly w.r.t. page numbers, \ref and \label. – John Kormylo Jan 06 '21 at 22:15
  • @JohnKormylo can you maybe refer to a guide or something that can help me understand better what you mean and how to achieve it with only \include and \includeonly? – rdbisme Jan 06 '21 at 22:20
  • 1
    See https://tex.stackexchange.com/questions/31334/how-to-create-individual-chapter-pdfs-from-included-texs – John Kormylo Jan 06 '21 at 22:28
  • 1
    Oh, and you don't have to use the command line for \includeonly, just put it into the preamble. – John Kormylo Jan 06 '21 at 22:34

0 Answers0