rpgtex / DND-5e-LaTeX-Template

LaTeX package to typeset material for the fifth edition of the "world's greatest roleplaying game".
MIT License
1.43k stars 307 forks source link

Question on how to separate personal code into style file. #120

Closed rjbprime closed 5 years ago

rjbprime commented 5 years ago

Referrencing BrianCriswell's comment here, how do i setup a style override for my guide? Googling doesn't seem to be helping with my questions.

I'm trying to separate my styling code from the release files, so that I can update the package code without overwriting my changes. I'm first getting an option clash with the selected packages I use in my override style.

Main.tex

% Changing book to article will make the footers match on each page,
% rather than alternate every other.
%
% Note that the article class does not have chapters.
\documentclass[letterpaper,10pt,twoside,twocolumn,openany]{book}

% Use babel or polyglossia to automatically redefine macros for terms
% Armor Class, Level, etc...
% Default output is in English; captions are located in lib/dndstring-captions.sty.
% If no captions exist for a language, English will be used.
%1. To load a language with babel:
%   \usepackage[<lang>]{babel}
%2. To load a language with polyglossia:
%   \usepackage{polyglossia}
%   \setdefaultlanguage{<lang>}
\usepackage[english]{babel}
%usepackage[italian]{babel}
% For further options (multilanguage documents, hypenations, language environments...)
% please refer to babel/polyglossia's documentation.

\usepackage[utf8]{inputenc}
\usepackage{hang}
\usepackage{lipsum}
\usepackage{listings}

\usepackage{dnd}

\lstset{%
  basicstyle=\ttfamily,
  language=[LaTeX]{TeX},
}

\usepackage{aig}

% Start document
\begin{document}

% End document
\end{document}

aig.sty

\RequirePackage{dnd}

\RequirePackage{color}
\RequirePackage{fancyhdr}
\RequirePackage[titles]{tocloft}
\RequirePackage{titlesec}   % Used to adjust (sub)section formatting

\usepackage[
  a4paper,
  left=9mm,
  right=9mm,
  %bindingoffset=4mm, % .2in
  hmargin=7mm,       % .7in
  top=10mm,           % .55in
  bottom=45pt,        % .7in
  footskip=30pt,      % makes the footer text line up with the graphic
]{geometry}

% Set paragraph and line spacing
\linespread{0.95}%
\setlength{\parindent}{0pt}
\setlength{\RaggedRightRightskip}{0pt plus 2mm}
\setlength{\RaggedRightParindent}{\parindent}
\hyphenpenalty=1000  % Fewer hyphens

% Columns setup
\setlength{\columnsep}{10mm}  % .35in

\iftoggle{multitoc}{%
  \RequirePackage[toc]{multitoc}
}{}

\definecolor{pagegold}{HTML}{4682B4}

\fancyfoot[LE]{
    \iftoggle{bool-footer-scroll}{
        \begin{tikzpicture}[remember picture,overlay]
            \node[xscale=-1,inner sep=0pt,anchor=south,nearly opaque] at (current page.south) {\includegraphics[width=\paperwidth,height=43pt]{img/footerscroll}};
            \node[xshift=40pt,yshift=25pt] at (current page.south west) {\dnd@PageNumberFont\textcolor{pagegold}{\thepage}};
            \node[anchor=south west,xshift=\marginparwidth+\marginparpush,yshift=22pt] at (current page.south west) {\dnd@FooterFont{\textcolor{pagegold}{\nouppercase\leftmark}}};
        \end{tikzpicture}
    }{
        \begin{tikzpicture}[remember picture,overlay]
      \node[anchor=south west,xshift=\marginparwidth-\marginparpush,yshift=\nobgfooterheight+2pt] at (current page.south west) {\dnd@PageNumberFont{\thepage}};
            \node[anchor=south west,xshift=\marginparwidth+\marginparpush,yshift=\nobgfooterheight] at (current page.south west) {\leftmark};
        \end{tikzpicture}
    }
}

\fancyfoot[RO]{
    \iftoggle{bool-footer-scroll}{
        \begin{tikzpicture}[remember picture,overlay]
            \node[inner sep=0pt,anchor=south,nearly opaque] at (current page.south) {\includegraphics[width=\paperwidth,height=43pt]{img/footerscroll}};
            \node[xshift=-40pt,yshift=25pt] at (current page.south east) {\dnd@PageNumberFont\textcolor{pagegold}{\thepage}};
            \node[anchor=south east,xshift=-\marginparwidth-\marginparpush,yshift=22pt] at (current page.south east) {\dnd@FooterFont{\textcolor{pagegold}{\nouppercase\leftmark}}};
        \end{tikzpicture}
    }{
        \begin{tikzpicture}[remember picture,overlay]
      \node[anchor=south east,xshift=-\marginparwidth+2\marginparpush,yshift=\nobgfooterheight+2pt] at (current page.south east) {\dnd@PageNumberFont{\thepage}};
            \node[anchor=south east,xshift=-\marginparwidth,yshift=\nobgfooterheight] at (current page.south east) {\leftmark};
        \end{tikzpicture}
    }
}

% Table Header
\newcommand{\header}[1]{{
    \par\vspace*{6pt}
    \noindent
    \dnd@TableTitleFont
    #1}}

% Centered Column
\newcolumntype{Y}{>{\centering\arraybackslash}X}

% Table Environment
\NewDocumentEnvironment{dndtable}{O{XX} O{tablecolor}}{%
    \par\vspace*{6pt}
    \noindent
    \dnd@TableBodyFont
    \rowcolors{1}{}{#2}
    \tabularx{\linewidth}{#1}
  }{%
    \endtabularx
    \vspace{6pt plus 2pt}
    \noindent
  }

\newenvironment{dnditemtable}[1][XX]{%
    \dnd@deprecate{dnditemtable}{0.7}[Set tablecolor and use dndtable instead.]
    \par\vspace*{6pt}
    \noindent
    \dnd@TableBodyFont
    \rowcolors{1}{}{DmgCoral}
    \tabularx{\linewidth}{#1}
  }{%
    \endtabularx
    \vspace{6pt plus 2pt}
    \noindent
  }

\titlespacing*{\chapter}{0pt}{0pt}{14pt}
BrianCriswell commented 5 years ago

It took me a while to get it all set up, and package option clashes where a big part of that (you only get 1 shot at including a package and those options stick). I would suggest a few things:

  1. Comment out all the \RequirePackage commands except for \RequirePackage{dnd}. Find the errors and include the missing packages back in.
  2. If you want to change an option in a package already included by dnd.sty, use \PassOptionsToPackage{option}{package}. I use this to pass the table option to the package xcolor.
  3. Use \newgeometry rather than including the geometry package again.
  4. Only include in your file what you actually want changed. dnditemtable is deprecated. Its only difference is a different color which can be used by passing in the optional tablecolor into dndtable. The Y column is already included in the dnd.sty file. There is no need to include it again, along with anything else that was just copied.
rjbprime commented 5 years ago

I've sorted through the code, and have it sorta working. It now places two blank pages at the start of the document as page 1 and 2. It then creates the title and TOC pages as 1.1 and 2.1 respectively. For my first page of content after the TOC, it then continues the page numbering from 3. Did you ever come across this?

Main.tex

% Changing book to article will make the footers match on each page,
% rather than alternate every other.
%
% Note that the article class does not have chapters.
\documentclass[a4paper,9pt,twoside,twocolumn,openany,table]{extbook}

% Use babel or polyglossia to automatically redefine macros for terms
% Armor Class, Level, etc...
% Default output is in English; captions are located in lib/dndstring-captions.sty.
% If no captions exist for a language, English will be used.
%1. To load a language with babel:
%   \usepackage[<lang>]{babel}
%2. To load a language with polyglossia:
%   \usepackage{polyglossia}
%   \setdefaultlanguage{<lang>}
\usepackage[english]{babel}
%usepackage[italian]{babel}
% For further options (multilanguage documents, hypenations, language environments...)
% please refer to babel/polyglossia's documentation.

\usepackage[utf8]{inputenc}
\usepackage{hang}
\usepackage{lipsum}
\usepackage{listings}

\usepackage{mathptmx}
\usepackage{anyfontsize}
\usepackage{t1enc}

\usepackage[usestackEOL]{stackengine}

\def\stackalignment{l}

\usepackage{fontspec}

%%\setlist{nolistsep}
\newfontfamily\Hyliafont[Ligatures=TeX]{Hylia Serif Beta}
\newcommand\Hylia[1]{{\Hyliafont #1}}

\usepackage{dnd}

\lstset{%
  basicstyle=\ttfamily,
  language=[LaTeX]{TeX},
}

\hyphenpenalty=9000

%Section Styling
\titleformat{\chapter}[display]
  {\bfseries\Huge}
  {\filright\MakeUppercase{\Hylia{\chaptertitlename}}\Huge\hspace{0.25cm}\Hylia\thechapter}
  {1ex}
  {\titlerule\vspace{1ex}\filleft\Hylia}
  [\vspace{1ex}\titlerule]

\titleformat{\section}[hang]
{}
{}
{0pt}
{\LARGE\bfseries\Hylia}
  [\vspace{1ex}\titlerule]

\titleformat{\subsection}[hang]
{}
{}
{0pt}
{\Large\bfseries\Hylia}

\titleformat{\subsubsection}[hang]
{}
{}
{0pt}
{\large\bfseries\Hylia}

\setlength{\parindent}{5mm}

%\usepackage{tikz}

\usepackage{graphicx}

\usepackage{tikz}

\usepackage{hyperref}
\hypersetup{
    pdfpagemode=UseOutlines,
    bookmarks=true,
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=black
}

\usepackage{bookmark}

\usepackage{aig}

% Start document
\begin{document}
\begin{titlepage}
\bookmark[page=1,level=-2]{The Adventures in Gaia}
\begin{tikzpicture}[remember picture,overlay]
   \node[opacity=0.7,anchor=north east,inner sep=0pt] at (current page.north east)
              {\includegraphics[width=215mm,height=300mm]{img/personal/coverpage}};
\end{tikzpicture}

    \begin{center}
        \vspace*{2cm}

        %\Huge
        \fontsize{60}{72}\Hylia{the Adventures in Gaia}

        \vfill

        \vspace{0.8cm}

        \fontsize{24}{29}\Hylia{by RJBPrime}        

        \vspace{0.8cm}

        \includegraphics[width=0.15\textwidth]{img/personal/waxseal}

        \vspace{0.8cm}

        \fontsize{12}{15}\Hylia{A homebrew campaign for the 5\textsuperscript{TH} edition of Worlds Greatest Tabletop RPG}

    \end{center}
\end{titlepage}
%\clearpage
\begin{multicols}{2}
%\vspace*{0mm}
\footnotesize
\hypertarget{tocpage}{}
\tableofcontents
\bookmark[dest=tocpage,level=-1]{Contents}
\normalsize
\end{multicols}

\raggedcolumns

% Your content goes here

% Comment this out if you're using the article class.
\chapter{Chapter 1: Table Guidelines}

% End document
\end{document}

aig.sty

\RequirePackage{dnd}

%\RequirePackage{color}
%\RequirePackage{fancyhdr}
%\RequirePackage[titles]{tocloft}
%\RequirePackage{titlesec}  % Used to adjust (sub)section formatting

\newgeometry{
  left=9mm,
  right=9mm,
  %bindingoffset=4mm, % .2in
  hmargin=7mm,       % .7in
  top=10mm,           % .55in
  bottom=45pt,        % .7in
  footskip=30pt,      % makes the footer text line up with the graphic
}

% Set paragraph and line spacing
\linespread{0.95}%
\setlength{\parindent}{0pt}
\setlength{\RaggedRightRightskip}{0pt plus 2mm}
\setlength{\RaggedRightParindent}{\parindent}
\hyphenpenalty=1000  % Fewer hyphens

% Columns setup
\setlength{\columnsep}{10mm}  % .35in

\definecolor{pagegold}{HTML}{4682B4}

\fancyfoot[LE]{
    \iftoggle{bool-footer-scroll}{
        \begin{tikzpicture}[remember picture,overlay]
            \node[xscale=-1,inner sep=0pt,anchor=south,nearly opaque] at (current page.south) {\includegraphics[width=\paperwidth,height=43pt]{img/footerscroll}};
            \node[xshift=40pt,yshift=25pt] at (current page.south west) {\dnd@PageNumberFont\textcolor{pagegold}{\thepage}};
            \node[anchor=south west,xshift=\marginparwidth+\marginparpush,yshift=22pt] at (current page.south west) {\dnd@FooterFont{\textcolor{pagegold}{\nouppercase\leftmark}}};
        \end{tikzpicture}
    }{
        \begin{tikzpicture}[remember picture,overlay]
      \node[anchor=south west,xshift=\marginparwidth-\marginparpush,yshift=\nobgfooterheight+2pt] at (current page.south west) {\dnd@PageNumberFont{\thepage}};
            \node[anchor=south west,xshift=\marginparwidth+\marginparpush,yshift=\nobgfooterheight] at (current page.south west) {\leftmark};
        \end{tikzpicture}
    }
}

\fancyfoot[RO]{
    \iftoggle{bool-footer-scroll}{
        \begin{tikzpicture}[remember picture,overlay]
            \node[inner sep=0pt,anchor=south,nearly opaque] at (current page.south) {\includegraphics[width=\paperwidth,height=43pt]{img/footerscroll}};
            \node[xshift=-40pt,yshift=25pt] at (current page.south east) {\dnd@PageNumberFont\textcolor{pagegold}{\thepage}};
            \node[anchor=south east,xshift=-\marginparwidth-\marginparpush,yshift=22pt] at (current page.south east) {\dnd@FooterFont{\textcolor{pagegold}{\nouppercase\leftmark}}};
        \end{tikzpicture}
    }{
        \begin{tikzpicture}[remember picture,overlay]
      \node[anchor=south east,xshift=-\marginparwidth+2\marginparpush,yshift=\nobgfooterheight+2pt] at (current page.south east) {\dnd@PageNumberFont{\thepage}};
            \node[anchor=south east,xshift=-\marginparwidth,yshift=\nobgfooterheight] at (current page.south east) {\leftmark};
        \end{tikzpicture}
    }
}

% Table Header
\renewcommand{\header}[1]{{
    \par\vspace*{6pt}
    \noindent
    \dnd@TableTitleFont
    #1}}

% Table Environment
\PassOptionsToPackage{dndtable}{O{XX} O{tablecolor}}{%
    \par\vspace*{6pt}
  }

\titlespacing*{\chapter}{0pt}{0pt}{14pt}
rjbprime commented 5 years ago

Anyone able to help with the sepeartion of style and code now placing two blank pages at the start of the document as page 1 and 2, creating the title and TOC pages as 1.1 and 2.1 respectively and first page of content after the TOC continuing the page numbering from 3?

EDIT: Okay, I have my code sorted, except that now I can't set it to one column on my title page, it defaults to 2 columns, and when I try to use the \begin{multicols}{1} (or \begin{multicols*}{1}) command, it makes it appear as 4 columns.

I also downloaded a fresh copy of the master zip, and extracted it into dnd in my D:\texmf\tex\latex\ folder, to see if anything was wrong.

Can someone more knowledgeable help me please? I'm unsure on what to search on TeX.SE

BrianCriswell commented 5 years ago

I will see if I can take a look at this by Tuesday.

BrianCriswell commented 5 years ago

The problem seems to be the titlepage environment. It seemed to fix itself after I commented that out.

% Changing book to article will make the footers match on each page,
% rather than alternate every other.
%
% Note that the article class does not have chapters.
\documentclass[a4paper,9pt,twoside,twocolumn,openany,table]{extbook}

    % Use babel or polyglossia to automatically redefine macros for terms
    % Armor Class, Level, etc...
    % Default output is in English; captions are located in lib/dndstring-captions.sty.
    % If no captions exist for a language, English will be used.
    %1. To load a language with babel:
    %   \usepackage[<lang>]{babel}
    %2. To load a language with polyglossia:
    %   \usepackage{polyglossia}
    %   \setdefaultlanguage{<lang>}
    \usepackage[english]{babel}
    %usepackage[italian]{babel}
    % For further options (multilanguage documents, hypenations, language environments...)
    % please refer to babel/polyglossia's documentation.

    \usepackage[utf8]{inputenc}
    \usepackage{hang}
    \usepackage{lipsum}
    \usepackage{listings}

    \usepackage{mathptmx}
    \usepackage{anyfontsize}
    \usepackage{t1enc}

    \usepackage[usestackEOL]{stackengine}

    \def\stackalignment{l}

    %\usepackage{fontspec}

    %%\setlist{nolistsep}
    %\newfontfamily\Hyliafont[Ligatures=TeX]{Hylia Serif Beta}
    %\newcommand\Hylia[1]{{\Hyliafont #1}}

    \usepackage{dnd}

    \lstset{%
      basicstyle=\ttfamily,
      language=[LaTeX]{TeX},
    }

    \hyphenpenalty=9000

    %Section Styling
    %\titleformat{\chapter}[display]
    %  {\bfseries\Huge}
    %  {\filright\MakeUppercase{\Hylia{\chaptertitlename}}\Huge\hspace{0.25cm}\Hylia\thechapter}
    %  {1ex}
    %  {\titlerule\vspace{1ex}\filleft\Hylia}
    %  [\vspace{1ex}\titlerule]

    %\titleformat{\section}[hang]
    %{}
    %{}
    %{0pt}
    %{\LARGE\bfseries\Hylia}
    %  [\vspace{1ex}\titlerule]

    %\titleformat{\subsection}[hang]
    %{}
    %{}
    %{0pt}
    %{\Large\bfseries\Hylia}

    %\titleformat{\subsubsection}[hang]
    %{}
    %{}
    %{0pt}
    %{\large\bfseries\Hylia}

    \setlength{\parindent}{5mm}

    %\usepackage{tikz}

    \usepackage{graphicx}

    \usepackage{tikz}

    \usepackage{hyperref}
    \hypersetup{
        pdfpagemode=UseOutlines,
        bookmarks=true,
        colorlinks,
        citecolor=black,
        filecolor=black,
        linkcolor=black,
        urlcolor=black
    }

    \usepackage{bookmark}

    \usepackage{aig}

    % Start document
    \begin{document}
    %\begin{titlepage}
    %\bookmark[page=1,level=-2]{The Adventures in Gaia}
    \begin{tikzpicture}[remember picture,overlay]
       \node[opacity=0.7,anchor=north east,inner sep=0pt] at (current page.north east)
                  {%\includegraphics[width=215mm,height=300mm]{img/personal/coverpage}
                  };
    \end{tikzpicture}

        \begin{center}
            \vspace*{2cm}

            %\Huge
            %\fontsize{60}{72}\Hylia{the Adventures in Gaia}

            \vfill

            \vspace{0.8cm}

            %\fontsize{24}{29}\Hylia{by RJBPrime}        

            \vspace{0.8cm}

            %\includegraphics[width=0.15\textwidth]{img/personal/waxseal}

            \vspace{0.8cm}

            %\fontsize{12}{15}\Hylia{A homebrew campaign for the 5\textsuperscript{TH} edition of Worlds Greatest Tabletop RPG}

        \end{center}
    %\end{titlepage}
    %\clearpage
    %\begin{multicols}{2}
    %\vspace*{0mm}
    \footnotesize
    %\hypertarget{tocpage}{}
    \tableofcontents
    \bookmark[dest=tocpage,level=-1]{Contents}
    \normalsize
    %\end{multicols}

    \raggedcolumns

    % Your content goes here

    % Comment this out if you're using the article class.
    \chapter{Chapter 1: Table Guidelines}

    % End document
    \end{document}
rjbprime commented 5 years ago

Probably should of posted the updated MWE code and TeX distribution. :pensive: I do apologise. I'm using MiKTeX 2.9, compiling with XeLaTeX (for the Hylia font to render), the code is below. Attached is a PDF of the following code compiled as a PDF, hopefully showing what I mean by the columns issue on the first page.

I tried previewing the code in the post box, but it seemed to not work properly, it rendered half of it outside the code box. So I zipped the two files and attached them.

test.pdf

AiG.zip

BrianCriswell commented 5 years ago

The PDF looks great! What's the problem?

rjbprime commented 5 years ago

The title page content (The Adventures in Gaia, my logo, the rest of the titel page text), is in one column of two, which hyphens part of the text. Before I seperated my style from the 0.6.0 code, I had the title page as one coloumn, with all the text and the logo, centred on the page.

As seen with files in my fork, which I'll link to this comment.

rjbprime/DND-5e-LaTeX-Template/AiG - PreSep.tex

rjbprime/DND-5e-LaTeX-Template/AiG - PreSep.pdf

BrianCriswell commented 5 years ago

Ah, I was only looking for empty pages between the title page and the toc.

So I added in \onecolumn after \begin{document} and saw the two skipped pages before the title page that you were referring to.

Here is your offending code in aig.sty.

\PassOptionsToPackage{dndtable}{O{XX} O{tablecolor}}{%
    \par\vspace*{6pt}
  }

dndtable is an environment, not a package. You are likely going to need to create your own version of the environment or a substitute (NewDocumentEnvironment vs RenewDocument Environment). I suspect that because \PassOptionsToPackage only takes two arguments, the third group (the curly braces) is being treated as information to pass into the document. That somehow causes the document to start before \begin{document} (or saves it for when the document starts). When \onecolumn is called, the document has to start a new page (I don't know why it is treating it like a \cleardouble), and the title starts on the third page of the document.

So I think removing the code referenced above will fix your issue. You might also want to take a look at the following command setup for main.tex which I found useful. I start my ToC on page 1 with the front and back cover being pages i and ii. This helps keep the RO / LE page order consistent between the PDF and Print on Demand versions.

\begin{document}
\onecolumn
\frontmatter
%\iftoggle{bool-pod}{}{%
    \cover%
    \backcover%
%}

\mainmatter%
\tableofcontents%

%Credits
\twocolumn

\chapter{Chapter 1 Name}
\input{chapter-1}

\chapter{Chapter 2 Name}
\input{chapter-2}

% and so on

\appendix

\chapter{Appendix A Name}
\input{app/appa}

\chapter{Appendix B\@: Items and Traps}
\input{app-a}

\backmatter%
\chapter{Legal Information}
\input{ogl}
\input{advertisement}

% and so on

\end{document}

\frontmatter switches to roman page numbers (i, ii, etc.) \mainmatter switchers to arabic page numbers (1, 2, etc.) \appendix switches chapter numbers to letters \backmatter doesn't really do anything yet as far as I understand, but it helps visually arrange the document.

BrianCriswell commented 5 years ago

I created a new page on the wiki with a stripped-down example of how I set up my custom style package. https://github.com/evanbergeron/DND-5e-LaTeX-Template/wiki/CustomStyleExample

rjbprime commented 5 years ago

That helps a bit. I've added bits from that example to my updated aig.sty file (current tex file). Now, when I compile, I get the following error:

`Runaway argument? [ ! Paragraph ended before \environment dndtable was complete.

\par l.215 \begin{aigtable}[cXXX][DmgSlateGrey]` I'm assuming its because I don't understand what options I'm missing from the \newenvironment command in my aig.sty file. I do apologise for taking up your time, and I do appreciate it. EDIT: Instead of renewing the command, I copied the dndtable command into my aig.sty file, renamed it, then changed what i wanted. I then renamed the various dndtable's in my tex file to my new command. it now does not get that error. I assume I was doing something wrong, but as you suggested, the NewDocumentEnvrionment command worked.
BrianCriswell commented 5 years ago

Yeah, tabularx, what dndtable is based on, does not lend itself to being overridden in a similar manner to what I did with sidebar.

rjbprime commented 5 years ago

Sorry I haven't responded earlier. With the help I have received from you, @BrianCriswell, I have resolved this issue for the time being. I'll close this issue, and if I have any more issues, I'll create a new thread.

rjbprime commented 5 years ago

I'm going to reopen this, as I've just spent the last couple of days pulling out my hair, trying to work out why the \twocolumn command is pushing my chapter headings outside my page margins. Setting the \onecolumn option fixes this particular problem, with a:

\begin{multicols*}{2}

code

\end{multicols*}

underneath the \chapter for the two columns. What could be breaking the \twocolumn option? Is there a difference to how \onecolumn is set up versus \twocolumn? Or would I need to add/change some parameters in my sty file?

BrianCriswell commented 5 years ago

I have found a slight difference in margins for \onecolumn vs. \twocolumn in my documents. Do you want to post a picture with the issue as well as the style code if you are making a change to the header formatting?

Since this is a new problem, how about opening a new issue instead?

rjbprime commented 5 years ago

One Column Test Page as a JPG (50% sized)

Test-OneColumn

Two Column Test Page as a JPG (50% sized)

Test-TwoColumn

My style code, relevent section is line 110 of the code, which moves the chapter spacing. Reproduced in the following line.

\titlespacing*{\chapter}{0pt}{-15pt}{5pt}

\ProvidesPackage{overridednd}

% Pass options to packages included by the dnd package to avoid package option clashes

% Require packages needed to set up package options for overridednd

% Set up package options for overridednd

\RequirePackage{dnd}
% Require other packages not already required by dnd that are used by code in this package

% Set variables and other package settings based on package options (setting booleans, declaring colors as RGB vs CMYK, etc.)

% Override parts of dnd that there is not a way to incorporate changes (fancyhead, dndtable, etc.)

% Override parts of dnd that can incorporate changes to the base package over time.

\definecolor{CharFillColor}{rgb}{1,1,1}

%\RequirePackage{color}
%\RequirePackage{fancyhdr}
%\RequirePackage[titles]{tocloft}
%\RequirePackage{titlesec}  % Used to adjust (sub)section formatting

\newgeometry{
  left=13.5mm,
  right=13.5mm,
  %bindingoffset=4mm, % .2in
  hmargin=8mm,       % .7in
  top=8mm,           % .55in
  bottom=40pt,        % .7in
  footskip=30pt,      % makes the footer text line up with the graphic
}

% Set paragraph and line spacing
\linespread{0.8}%
\setlength{\parindent}{0pt}
\setlength{\RaggedRightRightskip}{0pt plus 2mm}
\setlength{\RaggedRightParindent}{\parindent}
\hyphenpenalty=1000  % Fewer hyphens

% Columns setup
\setlength{\columnsep}{6mm}  % .35in

\definecolor{pagegold}{HTML}{1690A8}

\definecolor{pagegoldlight}{HTML}{F6FDFE}

\definecolor{rulered}{HTML}{9C2B1B}

% Trim (affects tables and paperboxes)
\definecolor{AigBlue}{HTML}{5D8AA8} % AiG Blue

% The color used in \setthemecolor when a new color is not set
\colorlet{themecolor}{AigBlue}    % Set the default theme to Part 1 of the PHB.

\definecolor{snow}{HTML}{FFFAFA}

\definecolor{night}{HTML}{000000}

\fancyhf{} % clear all headers and footers

\fancyhead{
  \iftoggle{bool-bg}{
    \begin{tikzpicture}[remember picture,overlay]
      \node[inner sep=0pt] at (current page.center) {\includegraphics[width=\paperwidth,height=\paperheight]{img/sotdl-background-small}};
    \end{tikzpicture}
  }{}
}

\fancyfoot[LE]{
        \begin{tikzpicture}[remember picture,overlay]
            \iftoggle{bool-footer-scroll}{%
                \node[xscale=-1,inner sep=0pt,anchor=south,nearly opaque,yshift=-4pt] at (current page.south) {\includegraphics[width=\paperwidth,height=38pt]{img/footer/footerscroll}};
            }{}
            \node[xshift=13.75pt,yshift=23pt] at (current page.south west) {\dnd@PageNumberFont\textcolor{night}{\thepage}};
            \node[anchor=base west, xshift=\marginparwidth+\marginparpush+2pt, yshift=25.75pt] at (current page.south west) {\dnd@FooterFont{\textcolor{night}{\nouppercase\leftmark}}};
        \end{tikzpicture}
}

\fancyfoot[RO]{
        \begin{tikzpicture}[remember picture,overlay]
            \iftoggle{bool-footer-scroll}{%
                \node[inner sep=0pt,anchor=south,nearly opaque,yshift=-4pt] at (current page.south) {\includegraphics[width=\paperwidth,height=38pt]{img/footer/footerscroll}};
            }{}
            \node[xshift=-13.75pt,yshift=23pt] at (current page.south east) {\dnd@PageNumberFont\textcolor{night}{\thepage}};
            \node[anchor=base east, xshift=-\marginparwidth-\marginparpush-2pt, yshift=25.75pt] at (current page.south east) {\dnd@FooterFont{\textcolor{night}{\nouppercase\leftmark}}};
        \end{tikzpicture}
}

% Table Header
\renewcommand{\header}[1]{{
    \par\vspace*{8pt}
    \noindent
    \dnd@TableTitleFont
    #1}}

\NewDocumentEnvironment{aigtable}{O{XX} O{tablecolor}}{%
    \par\vspace*{6pt}
    \noindent
    \dnd@TableBodyFont
    \rowcolors{1}{}{#2}
    \tabularx{\linewidth}{#1}
  }{%
    \endtabularx
    \vspace{6pt plus 1pt}
    \noindent
  }

\titlespacing*{\chapter}{0pt}{-15pt}{5pt}

\DeclareTColorBox{classbox}{m O{}}{%
  colbacktitle=snow,
  colback=snow,
  coltitle=black,
  fonttitle=\dnd@TableTitleFont,
  enhanced,
  lower separated=false,
  frame code={%
    \newcommand{\dnd@classbox@innerframe}{%
      (frame.north west) %-- ++(0,0)
      %arc(180:270:0mm)
      %[sharp corners]
      -- (frame.north east)
     % arc(-90:0:0mm)
      %[sharp corners]
      -- (frame.north east) -- (frame.south east)
      %[sharp corners]
      %-- ++(0,0)
      %arc(0:90:0mm)
      -- (frame.south west)
      %arc(90:180:0mm)
      %[sharp corners]
      -- (frame.south west)
      -- cycle
    }
    \newcommand{\dnd@classbox@outerframetop}{%
      ([xshift=0,yshift=-4mm]frame.north west)
      -- ++(-1.5mm,0)
      -- ++(0,5.5mm) arc(-90:0:0mm)
      [sharp corners]
      -- ++(5.5mm,0) arc(0:90:0mm)
      [sharp corners]
      -- ([xshift=4mm]frame.north west)
    }
    \newcommand{\dnd@classbox@outerframebottom}{%
      ([xshift=-4mm,yshift=0mm]frame.south east)
      -- ++(0,-1.5mm)
      -- ++(5.5mm,0) arc(-90:0:0mm)
      [sharp corners]
      -- ++(0,5.5mm) arc(0:90:0mm)
      [sharp corners]
      -- ([yshift=4mm]frame.south east)
    }
    \begin{scope}
      % Draw the box interior (fill).
      \clip \dnd@classbox@outerframetop -- \dnd@classbox@outerframebottom -- cycle;
      %\fill[white]
      \dnd@classbox@innerframe;
    \end{scope}
    \begin{scope}[draw=pagegold]
      % Draw the frame.
      \draw[double=pagegoldlight, double distance=1.2pt, semithick]
      \dnd@classbox@outerframetop
      \dnd@classbox@outerframebottom
      \dnd@classbox@innerframe;
    \end{scope}
  },
  opacityfill=1,
  title=#1,
  size=minimal,
  % Override spacing set by `size`.
  bottom=2mm,
  boxsep=1.5mm,
  toptitle=2mm,
  % Inject user settings.
  #2,
}{%
}

\newcommand{\commandheader}[7]{
  \subtitlesection{#1}{#2}
  \vspace{-1ex} % subtitlesection artefact; topsep also changes bottom spacing.
  \begin{description}[font=\normalfont\textbf,noitemsep,topsep=1ex,leftmargin=1em]
    \item[Action:] #3
    \item[Target:] #4
    \item[Range:] #5
    \item[Cost:] #6
    \item[Special:] #7
  \end{description}
}

\newenvironment{command}[7]
  {\commandheader{#1}{#2}{#3}{#4}{#5}{#6}{#7}}
  % Environment encloses description.
{\vspace{\baselineskip}}

\newcommand{\tacticheader}[6]{
  \subtitlesection{#1}{#2}
  \vspace{-1ex} % subtitlesection artefact; topsep also changes bottom spacing.
  \begin{description}[font=\normalfont\textbf,noitemsep,topsep=1ex,leftmargin=1em]
    \item[Action:] #3
    \item[Target:] #4
    \item[Range:] #5
    \item[Usage:] #6
  \end{description}
}

\newenvironment{tactic}[6]
  {\tacticheader{#1}{#2}{#3}{#4}{#5}{#6}}
  % Environment encloses description.
{\vspace{\baselineskip}}

\RequirePackage{fontspec}

\setmainfont[Mapping=tex-text]{Spectral}
\setsansfont[Mapping=tex-text,Numbers=Lining]{Alegreya Sans}
\newfontfamily\titlefont[Mapping=tex-text,Numbers=Lining]{Spectral SC}
\newfontfamily\sanstitlefont[Mapping=tex-text,Numbers=Lining]{Alegreya Sans SC}

\renewcommand{\dnd@TitleFont}{\titlefont}

\renewcommand{\dnd@TableTitleFont}{\sanstitlefont\selectfont\bfseries\scshape}
\renewcommand{\dnd@TableBodyFont}{\sffamily}

\renewcommand{\dnd@BoxTitleFont}{\sanstitlefont\selectfont\bfseries\scshape}
\renewcommand{\dnd@BoxBodyFont}{\sffamily}

\renewcommand{\dnd@StatBlockTitleFont}{\normalfont\bfseries\scshape}
\renewcommand{\dnd@StatBlockSubtitleFont}{\sanstitlefont\selectfont\scshape}
\renewcommand{\dnd@StatBlockBodyFont}{\sffamily}

\renewcommand{\dnd@FooterFont}{\normalfont\scshape}
\renewcommand{\dnd@PageNumberFont}{\normalfont}
BrianCriswell commented 5 years ago

And the main.tex file for both versions?

rjbprime commented 5 years ago

TwoColumn Test code:

% Changing book to article will make the footers match on each page,
% rather than alternate every other.
%
% Note that the article class does not have chapters.
\documentclass[a4paper,8pt,twoside,twocolumn,openany,table]{extbook}

\usepackage[layout=true]{dnd}

% Use babel or polyglossia to automatically redefine macros for terms
% Armor Class, Level, etc...
% Default output is in English; captions are located in lib/dndstring-captions.sty.
% If no captions exist for a language, English will be used.
%1. To load a language with babel:
%   \usepackage[<lang>]{babel}
%2. To load a language with polyglossia:
%   \usepackage{polyglossia}
%   \setdefaultlanguage{<lang>}
\usepackage[english]{babel}
%usepackage[italian]{babel}
% For further options (multilanguage documents, hypenations, language environments...)
% please refer to babel/polyglossia's documentation.

\addto\captionsenglish{% Replace "english" with the language you use
  \renewcommand{\contentsname}%
    {Table of Contents}%
}

\usepackage[utf8]{inputenc}
\usepackage{hang}
% \usepackage{lipsum}
\usepackage{listings}

\usepackage{mathptmx}
\usepackage{anyfontsize}
\usepackage{t1enc}

\usepackage[usestackEOL]{stackengine}

\def\stackalignment{l}

%\usepackage{xcolor}

\usepackage{pdfrender}

\usepackage{fontspec}

%%\setlist{nolistsep}

%\usepackage{dnd}

\usepackage{amssymb}

\usepackage{modernaig} % Name of personal .sty file

\lstset{%
  basicstyle=\ttfamily,
  language=[LaTeX]{TeX},
}

\hyphenpenalty=9000

\setlength{\parindent}{5mm}

\usepackage{graphicx}

\usepackage{tikz}

\usepackage{hyperref}
\hypersetup{
    pdfpagemode=UseOutlines,
    bookmarks=true,
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=black
}

\usepackage{bookmark}

\usepackage{datetime2}

% Start document
\begin{document}

\raggedcolumns

% Your content goes here

\twocolumn

% Comment this out if you're using the article class.
\chapter{Test TwoColumn}

%\begin{multicols*}{2}

\clearpage

% End document
\end{document}

OneColumn Test code

% Changing book to article will make the footers match on each page,
% rather than alternate every other.
%
% Note that the article class does not have chapters.
\documentclass[a4paper,8pt,twoside,twocolumn,openany,table]{extbook}

\usepackage[layout=true]{dnd}

% Use babel or polyglossia to automatically redefine macros for terms
% Armor Class, Level, etc...
% Default output is in English; captions are located in lib/dndstring-captions.sty.
% If no captions exist for a language, English will be used.
%1. To load a language with babel:
%   \usepackage[<lang>]{babel}
%2. To load a language with polyglossia:
%   \usepackage{polyglossia}
%   \setdefaultlanguage{<lang>}
\usepackage[english]{babel}
%usepackage[italian]{babel}
% For further options (multilanguage documents, hypenations, language environments...)
% please refer to babel/polyglossia's documentation.

\addto\captionsenglish{% Replace "english" with the language you use
    \renewcommand{\contentsname}%
    {Table of Contents}%
}

\usepackage[utf8]{inputenc}
\usepackage{hang}
% \usepackage{lipsum}
\usepackage{listings}

\usepackage{mathptmx}
\usepackage{anyfontsize}
\usepackage{t1enc}

\usepackage[usestackEOL]{stackengine}

\def\stackalignment{l}

%\usepackage{xcolor}

\usepackage{pdfrender}

\usepackage{fontspec}

%%\setlist{nolistsep}

%\usepackage{dnd}

\usepackage{amssymb}

\usepackage{modernaig} % Name of personal .sty file

\lstset{%
    basicstyle=\ttfamily,
    language=[LaTeX]{TeX},
}

\hyphenpenalty=9000

\setlength{\parindent}{5mm}

\usepackage{graphicx}

\usepackage{tikz}

\usepackage{hyperref}
\hypersetup{
    pdfpagemode=UseOutlines,
    bookmarks=true,
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=black
}

\usepackage{bookmark}

\usepackage{datetime2}

% Start document
\begin{document}

    \raggedcolumns

    % Your content goes here

\onecolumn

% Comment this out if you're using the article class.
\chapter{Test OneColumn}

\clearpage

% End document
\end{document}