文本变量忽略嵌套格式

文本变量忽略嵌套格式

我正在尝试在课程中制作标题页,以供将来在大学中使用。我希望用户能够在 main.tex 中设置标题,然后 custom.cls 将使其变大并变为大写,同时保留换行符的格式。我\uppercase在变量上使用了它,但它忽略了它以及\large它所包含的内容。我该如何解决这个问题?

自定义.cls:

\NeedsTeXFormat{LaTeX2e}[1996/12/01]
\ProvidesClass{UMLThesis}[2018/05/09]
\LoadClass[12pt,letterpaper,oneside,openright]{book}

%% ===================================================================================================
\usepackage{calc}
\usepackage{setspace}
\usepackage{vmargin}
\usepackage{ragged2e}

%% ===================================================================================================
\newlength{\remaining}
\newcommand{\supervisorSig}[1]{%
    \justifying
    \begin{singlespacing}
        \setlength{\remaining}{\textwidth-\widthof{\textbf{Signature of Thesis Supervisor: }}}
        \noindent \textbf{Signature of Thesis Supervisor:  }\underline{\hspace{\remaining}}\par
        \setlength{\remaining}{\textwidth-\widthof{\textbf{Name Typed:}\quad\quad\quad\quad#1}}
        \noindent \textbf{Name Typed:}\quad\quad\quad\quad\underline{#1\hspace{\remaining}}\par
        \vspace{2\baselineskip}
        \noindent \textbf{Signatures of Other Thesis Committee Members:}\par
    \end{singlespacing}
}

%% ===================================================================================================
\newcommand{\committeeMember}[1]{%
    \justifying
    \begin{singlespacing}
        \setlength{\remaining}{\textwidth-\widthof{\small \textbf{Committee Member Signature: }}}
        \noindent \textbf{Committee Member Signature: }\underline{\hspace{\remaining}} \par
        \setlength{\remaining}{\textwidth-\widthof{\small \textbf{Name Typed:}\quad\quad\quad\quad#1}}
        \noindent \textbf{Name Typed:}\quad\quad\quad\quad\underline{#1\hspace{\remaining}}\par
    \end{singlespacing}
}

\newcommand{\prevDegree}[3]{%
    #1 \uppercase{#2} (#3)}

%% ===================================================================================================
\newlength{\authline}
\newlength{\autharea}
\newlength{\dateline}
\newcommand\SignaturePage[6]{%
    \thispagestyle{empty}
    \begin{singlespacing}
        \vspace*{0.5 in}
        \uppercase{%
            \centering
            % Title of thesis
            \large{\uppercase{#1}} \par
            %Author section, and previous degrees
            \normalsize{\vspace{2\baselineskip} \par BY \vspace{2\baselineskip} \par \MakeUppercase{\authornames} \par #2 \vspace{3\baselineskip} \par
            submitted in partial fulfillment of the requirements \par
            % degree title
            for the degree of \MakeUppercase{\degreeName} \par
            % department name
            \MakeUppercase{\deptName} \par
            \MakeUppercase{\univName} \par}}
    \end{singlespacing}
    \vfill

    \small{%
        \setlength{\authline}{3.75 in-\widthof{\small{\textbf{Author:} }}}
        \setlength{\autharea}{\widthof{\small{\textbf{Author:} }}+\authline}
        \setlength{\dateline}{5.75 in-\autharea-\widthof{\small{ \textbf{Date:} }}}

        \justifying

        \begin{singlespacing}
            \noindent \textbf{Signature of} \par
            \noindent \textbf{Author:} \underline{\hspace{\authline}} \textbf{Date:} \underline{\hspace{\dateline} } \par
        \end{singlespacing}
        \noindent #3
        \committeeMember{#4}
        \committeeMember{#5}
        \committeeMember{#6} }
\cleardoublepage}

%% ===================================================================================================
\newcommand*{\titleF}[1]{\newcommand{\titleFmat}{#1}}
\newcommand*{\authors}[1]{\newcommand{\authornames}{#1}}
\newcommand*{\faculty}[2]{\newcommand{\facName}{#1}\newcommand{\facTitle}    {#2}}
\newcommand*{\degree}[2]{\newcommand{\degreeNameShort}{#1}\newcommand{\degreeName}{#2}}
\newcommand*{\department}[1]{\newcommand{\deptName}{#1}}
\newcommand*{\university}[1]{\newcommand{\univName}{#1}}

%% ===================================================================================================
\doublespacing
\setmarginsrb           { 1.5in}  % left margin
                        { 1.0in}  % top margin
                        { 1.0in}  % right margin
                        { 1.0in}  % bottom margin
                        {  20pt}  % head height
                        {0.25in}  % head sep
                        {   9pt}  % foot height
                        { 0.3in}  % foot sep

MWE .tex

\documentclass[letterpaper, 12pt, oneside]{UMLThesis}

\begin{document}
\frontmatter      % Begin Roman style (i, ii, iii, iv...) page numbering

% Set up the Title Page
\titleF     {This is a formattable \\ thesis title, and seems to \\ work without error}
\authors    {My name} %call with \authorNames
\faculty    {My PI}{King professor guy} %call with \facName and \facTitle
\department {Department within College} %call with \depName
\degree     {M.S.}{Masters of Science} %call with \degreeNameShort and \degreeName
\university {University of Massachusetts Lowell} %call with \univName

% Define the page headers using the FancyHdr package and set up for one-sided printing

\SignaturePage{%
%        Manually labeling the \\ manually spaced \\ title page % this line does not cause errors and looks correct
        \titleFmat % This ignores the encased formatting
    }{%
        % Input your previous degrees from least to most prestigious using the \prevdegree{abbreviation}{university}{year} function as show, and '\\' as manual line breaks between each degree
        \prevDegree{B.S.}{University of Massachusetts Lowell}{2014} 
    }{%
        % Create the signatures
        \supervisorSig{\ } % Use this for a master's thesis
        %\dissertationSig{\facName, Ph.D.} % Use this for a doctorate thesis
    }{%
        % First committee member
        \
    }{%
        % Second committee member
        \ 
    }{%
        % Third committee member
        \ 
    }
\clearpage  % Declaration ended, now start a new page

\mainmatter

\end{document}

答案1

看起来仍然过于复杂,但我修复了大写字母和大小命令误用的主要问题,并\\在以下范围内变得健壮:\centering

在此处输入图片描述

\NeedsTeXFormat{LaTeX2e}[1996/12/01]
\ProvidesClass{UMLThesis}[2018/05/09]
\LoadClass[12pt,letterpaper,oneside,openright]{book}

%% ===================================================================================================
\usepackage{calc}
\usepackage{setspace}
\usepackage{vmargin}
\usepackage{ragged2e}

%% ===================================================================================================
\newlength{\remaining}
\newcommand{\supervisorSig}[1]{%
    \justifying
    \begin{singlespacing}
        \setlength{\remaining}{\textwidth-\widthof{\textbf{Signature of Thesis Supervisor: }}}
        \noindent \textbf{Signature of Thesis Supervisor:  }\underline{\hspace{\remaining}}\par
        \setlength{\remaining}{\textwidth-\widthof{\textbf{Name Typed:}\quad\quad\quad\quad#1}}
        \noindent \textbf{Name Typed:}\quad\quad\quad\quad\underline{#1\hspace{\remaining}}\par
        \vspace{2\baselineskip}
        \noindent \textbf{Signatures of Other Thesis Committee Members:}\par
    \end{singlespacing}
}

%% ===================================================================================================
\newcommand{\committeeMember}[1]{%
    \justifying
    \begin{singlespacing}
        \setlength{\remaining}{\textwidth-\widthof{\small \textbf{Committee Member Signature: }}}
        \noindent \textbf{Committee Member Signature: }\underline{\hspace{\remaining}} \par
        \setlength{\remaining}{\textwidth-\widthof{\small \textbf{Name Typed:}\quad\quad\quad\quad#1}}
        \noindent \textbf{Name Typed:}\quad\quad\quad\quad\underline{#1\hspace{\remaining}}\par
    \end{singlespacing}
}

\newcommand{\prevDegree}[3]{%
    #1 \uppercase{#2} (#3)}

%% ===================================================================================================
\newlength{\authline}
\newlength{\autharea}
\newlength{\dateline}
\newcommand\SignaturePage[6]{%
    \thispagestyle{empty}
    \begin{singlespacing}
        \vspace*{0.5 in}
            \centering
            % Title of thesis
            {\large\let\\\par\MakeUppercase{#1}\par}
            %Author section, and previous degrees
            \vspace{2\baselineskip}%
            BY\par
            \vspace{2\baselineskip}%
            \MakeUppercase{\authornames}\par
            #2\par
            \vspace{3\baselineskip}%
            SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENTS\\%
            % degree title
            FOR THE DEGREE OF \MakeUppercase{\degreeName}\\%
            % department name
            \MakeUppercase{\deptName}\\%
            \MakeUppercase{\univName}\par
    \end{singlespacing}
    \vfill

    \small
        \setlength{\authline}{3.75 in-\widthof{\textbf{Author: }}}
        \setlength{\autharea}{\widthof{\textbf{Author:} }+\authline}
        \setlength{\dateline}{5.75 in-\autharea-\widthof{ \textbf{Date:} }}


        \begin{singlespacing}
            \noindent \textbf{Signature of}\par
            \noindent \textbf{Author:} \underline{\hspace{\authline}} \textbf{Date:} \underline{\hspace{\dateline} } \par
        \end{singlespacing}
        \noindent #3
        \committeeMember{#4}
        \committeeMember{#5}
        \committeeMember{#6}
\cleardoublepage}

%% ===================================================================================================
\newcommand*{\titleF}[1]{\newcommand{\titleFmat}{#1}}
\newcommand*{\authors}[1]{\newcommand{\authornames}{#1}}
\newcommand*{\faculty}[2]{\newcommand{\facName}{#1}\newcommand{\facTitle}    {#2}}
\newcommand*{\degree}[2]{\newcommand{\degreeNameShort}{#1}\newcommand{\degreeName}{#2}}
\newcommand*{\department}[1]{\newcommand{\deptName}{#1}}
\newcommand*{\university}[1]{\newcommand{\univName}{#1}}

%% ===================================================================================================
\doublespacing
\setmarginsrb           { 1.5in}  % left margin
                        { 1.0in}  % top margin
                        { 1.0in}  % right margin
                        { 1.0in}  % bottom margin
                        {  20pt}  % head height
                        {0.25in}  % head sep
                        {   9pt}  % foot height
                        { 0.3in}  % foot sep

相关内容