0

I am trying to make a science magazine (free ebook) that will contain a collection of science and math articles from different authors. I have come with the following MWE:

Current test_style.sty

% !TEX root = main.tex
% \RequirePackage[banglamainfont=Kalpurush,      % For writing Bangla. but not necessary for the MWE
%                 banglattfont=Kalpurush,
%                ]{latexbangla}

% table of contents formatting
\RequirePackage{tocloft}
\def\cftchapteraftersnum{.} % Tried to put a full stop after chapter numbers in ToC. But not working! % \renewcommand\cftchapafterpnum{\vskip-5pt} % Decreasing the line spacing between the names of chapters

\RequirePackage{placeins}

\RequirePackage{docmute} \RequirePackage{amsmath, amsfonts, amssymb, amsthm} %\RequirePackage{physics} \RequirePackage{graphicx} \RequirePackage{mathtools} \RequirePackage{extarrows} \RequirePackage{enumitem} \RequirePackage{lipsum} \RequirePackage{mwe} \RequirePackage[papersize={5.5in, 8.5in}, margin=0.8in, headheight=14.72pt]{geometry} \linespread{1.15}

\RequirePackage{csquotes} % https://tex.stackexchange.com/q/39285/114006 \RequirePackage{hyperref} \hypersetup{ colorlinks=true, linkcolor=blue, filecolor=magenta, urlcolor=cyan, } \urlstyle{same}

% Adding header ann footer on pages \RequirePackage{fancyhdr} \fancypagestyle{plain}{ \fancyhf{} % clear all header and footer fields \lhead{\spaceskip=5pt\href{<url>}{Magazine Name}} \cfoot{\thepage} \renewcommand{\headrulewidth}{0.5pt} \renewcommand{\footrulewidth}{0.5pt} }

\RequirePackage{pdfpages}

\allowdisplaybreaks

\graphicspath{ {./img/} }

\RequirePackage{titling}

\RequirePackage{titlesec} \titleformat{\chapter}[display] {\raggedright\normalfont\huge\bfseries}{{\Huge\S,}\ \thechapter}{20pt}{\Huge}

\titlespacing*{\chapter} {0pt}{0pt}{40pt} % this alters "before" spacing (the second length argument) to 0

% Adding Chapter Authors after chapter title: https://tex.stackexchange.com/a/156865/114006 \RequirePackage{suffix}

\newcommand\chapterauthor[1]{\authortoc{#1}\printchapterauthor{#1}} \WithSuffix\newcommand\chapterauthor*[1]{\printchapterauthor{#1}}

\makeatletter \newcommand{\printchapterauthor}[1]{% {\parindent0pt\vspace{-25pt}% \linespread{1.1}\spaceskip=7pt\Large\scshape#1% \par\nobreak\vspace{35pt}} @afterheading% } \newcommand{\authortoc}[1]{% \addtocontents{toc}{\vskip-10pt}% \addtocontents{toc}{% \protect\contentsline{chapter}% {\hskip1.5em\mdseries\scshape\protect\footnotesize#1}{}{}} \addtocontents{toc}{\vskip-5pt}% } \makeatother

% Command for chapter title photo % https://tex.stackexchange.com/a/91620/114006 \newcommand{\chapterphoto}[1]{\includegraphics[width=\textwidth]{#1}\vspace{0.5cm}}

Current test_title.tex

\title{
\includegraphics[width=0.5\textwidth]{example-image}~\\[1cm]
A Collection of Articles}
\author{Edited by\\
Editor 1 Name\\
Editor 2 Name\\}
\date{}

\begin{titlepage} \includepdf[pages=1, fitpaper]{cover} \thispagestyle{empty} \predate{\centering} \postdate{\vfill\hfill \footnotesize{\Designed by \ Designer \ © \href{<url>}{Book Template Source}\}\hfill} % https://tex.stackexchange.com/a/199356/114006 \maketitle \end{titlepage}

\pagenumbering{roman} \newpage \setcounter{tocdepth}{0} \tableofcontents \newpage \pagestyle{plain} \pagenumbering{arabic}

Current main.tex

% !TEX program = xelatex
\documentclass[12pt, oneside]{book}
\usepackage{test_style}

\begin{document}

\frontmatter

\include{test_title}

\mainmatter

%article 1 ------------- edit its names as necessary \chapter[Chapter One Title on ToC]{ % Short chapter title to show on the table of contents \chapterphoto{example-image-golden}
\href{<chapter url>}{Chapter One Title: Introduction}} % Full chapter title to show on the chapter title page \chapterauthor{\href{<author url>}{Author}} % Chapter author name with url \newpage \section{Introduction} \lipsum

\end{document}


Now I want to configure the test_style.sty and test_title.tex, so that I can generate the same output with some more additional features by setting custom commands. The configuration should be in such a way that the main.tex can be like:

My desired main.tex

% !TEX program = xelatex
\documentclass[12pt, oneside]{book}
\usepackage{test_style}

\begin{document}

\bookcover{cover}
\booklogo{example-image}
\booktitle{A collection of Articles}
\bookeditor{Editor 1 Name\ Editor 2 Name} \bookdesigner{Designer Name} % These are currenly done in my `test_title.tex' file. but I want to get them by the above commands. \pageheader{Book Name} \bookurl{<book url>} % Hyperlink on the page header

\chapter[Chapter One Title on ToC]{Chapter One Title: Introduction} \chapterphoto{example-image-golden} % The photo size should be optimized such that the chapter number, photo, name and author name always remain in the same page
\chapterurl{<chapter url>} % Hyperlink on the chapter title, link to the web version of the chapter, but this url should not be on ToC
\chapterauthor{Chapter Author Name} % Chapter author name \chapterauthorurl{<author url>} % Hyperlink on the author name, link to the author website, but the url should not be on ToC

\newpage \section{Introduction} \lipsum

\end{document}

I think my question can be separated into two main parts:

  • Making book-related custom commands \book...
  • Making chapter-related custom commands \chapter...

Basically, I wish to configure the style file and set those custom commands such that a user needs to work and edit in the main.tex file only, not necessarily in test_style.sty or test_title.tex. How to obtain these features? (And kindly don't miss reading the comments in main.tex).

Looking forward to get your answers! I know it has become a big question. But I felt that making these custom commands would be interconnected. So, I've put these questions together. But feel free to answer any specific portion of my question separately.

raf
  • 633
  • You have a lot of questions that may delay receiving good answers. I think it's better to delete this question and try to post each of your questions separately. – hesham May 29 '21 at 12:01
  • Thanks for the suggestion. But I don't wish to delete it. I can reduce the additional questions. But the issues of making custom commands are seemed interconnected to me. Hope it's okay to keep them together here! Also, everyone is welcomed to answer on any specific part! – raf May 29 '21 at 12:14

0 Answers0