如何在 \maketitle 中包含 \newcommand

如何在 \maketitle 中包含 \newcommand

這是我第一次使用 LaTeX,我真的需要幫助。我正在做我的大學研討會報告。

我無法使新命令\namesig出現在標題頁上。

在此輸入影像描述

這是.tex程式碼

\documentclass[a4 paper,12pt]{report}
\usepackage[hmargin=4.5cm,
vmargin=4.5cm]{geometry} 
%%Name of the Title and subtitle
\title{%
  The uIP Stack \\
  \large A Small Memory Footprint TCP/IP Stack for Microcontrollers\\
  } 
%% First Page of the Report
\author{Mohammad Arshad Ali \\ 
{ECE-A}\\
{B.E. 4/4}\\
{2451-15-735-040}\\
}
%% Signature of the Guide
\newcommand{\namesig}[2][5cm]{%
\begin{tabular}{@{}p{#1}@{}}
    #2 \\[2\normalbaselineskip] \hrule \\[0pt]
    {\small \textit{Signature}} 
  \end{tabular}
}

\begin{document}
\maketitle
\noindent \namesig{Dr. K. Usha}\hfill \namesig{Sudhir Dakey}
\end{document}

我知道以前有很多與此非常相似的帖子,但我無法正確結合原始程式碼。

另外請建議我,在哪裡可以找到適合我的要求的源代碼,即文檔或教科書,我可以在其中找到帶有一些解釋的源代碼。

答案1

您可以重新定義\maketitle來執行您需要的操作:

在此輸入影像描述

\documentclass[a4 paper,12pt]{report}
\usepackage[hmargin=4.5cm,
vmargin=4.5cm]{geometry} 
%%Name of the Title and subtitle
\title{%
    The uIP Stack \\
    \large A Small Memory Footprint TCP/IP Stack for Microcontrollers\\
} 
%% First Page of the Report
\author{Mohammad Arshad Ali \\ 
    {ECE-A}\\
    {B.E. 4/4}\\
    {2451-15-735-040}
}
%% Signature of the Guide
\newcommand{\namesig}[2][5cm]{%
    \begin{tabular}{@{}p{#1}@{}}
        #2 \\[2\normalbaselineskip] \hrule \\[0pt]
        {\small \textit{Signature}} 
    \end{tabular}
}
\makeatletter
\renewcommand{\maketitle}{
    \begin{center}

        \pagestyle{empty}
        \phantom{.}  %necessary to add space on top before the title
        \vspace{3cm}

        {\Huge \bf \@title\par}
        \vspace{2.5cm}

        {\LARGE \@author}\\[1cm]

        {\Large\@date}

        \vspace{4.5cm}
    \noindent \namesig{Dr. K. Usha}\hfill \namesig{Sudhir Dakey}
        %if you want something in the bottom of the page just use /vfill before that.

    \end{center}
}\makeatother

\begin{document}
    \maketitle
\end{document}

答案2

在環境的幫助下,titlepage你可以達成這樣的目標。當然,您可以根據需要調整字體大小、對齊方式和距離:

在此輸入影像描述

\documentclass[a4 paper,12pt]{report}
\usepackage[hmargin=4.5cm,vmargin=4.5cm]{geometry} 

\newcommand{\namesig}[2][5cm]{%
\begin{tabular}{@{}p{#1}@{}}
    #2 \\[2\normalbaselineskip] \hrule \\[0pt]
    {\small \textit{Signature}} 
  \end{tabular}
}

\begin{document}
\begin{titlepage}
\centering
\vspace*{2cm}
\LARGE The uIP Stack 

\large A Small Memory Footprint TCP/IP Stack for Microcontrollers
\vspace{2cm}

Mohammad Arshad Ali \\ 
{ECE-A}\\
{B.E. 4/4}\\
{2451-15-735-040}\\
\vspace{1cm}

\today

\vspace{5cm}

\namesig{Dr. K. Usha}\hfill \namesig{Sudhir Dakey}

\end{titlepage}
\end{document}

相關內容