我正在使用下面的代码来开发课程大纲。我尝试了不同的方法来添加图像在文档每页的右上角,同时将出现在第二页上的页眉移动到文档页面的底部。
\documentclass[PS,11pt]{syllabus}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{url}
\usepackage[small,compact]{titlesec}
\usepackage{xcolor}
\usepackage{lipsum}
% Reduce spacing between itemize
\let\tempone\itemize
\let\temptwo\enditemize
\renewenvironment{itemize}{\tempone\addtolength{\itemsep}{-.5\baselineskip}}{\temptwo}
% Roman section numbers
\renewcommand{\thesection}{\Roman{section}}
\usepackage[pdftex, bookmarksopen=true, bookmarksnumbered=true,
pdfstartview=FitH, breaklinks=true, urlbordercolor={0 1 1}, citebordercolor={0 1 0}, colorlinks = true]{hyperref}
% To eliminate the newline after \subsubsection
\titleformat{\subsubsection}[runin]{}{}{}{}[]
% Shade within enumerate
\usepackage[framemethod=TikZ]{mdframed}
\newmdenv[backgroundcolor=gray!40,roundcorner=10pt,nobreak=true]{shaded}
% Dot after section number
\titlelabel{\thetitle.\quad}
\textheight 9in
\textwidth 6.5in
\topmargin -.5in
\oddsidemargin 0in
\evensidemargin 0in
\newcommand{\percent}{\ensuremath{\%\;}}
\begin{document}
\title{\textbf{Course Title} \\
\vspace{.2cm}
Syllabus}
\name{Professor\\
\vspace{.2cm}Year}
\businessAddress{\emph{Room}: TBD \\ \emph{Time}: Tuesday/Thursday
5:00-6:20pm\\
\emph{Prerequisites}: None
}
\homeAddress{
\emph{Email}:
\href{mailto:[email protected]}{\color{gray}{[email protected]}}\\
\emph{Office Hour}: Thu 11:00am-Noom, sign up
\href{TBD}{\color{gray}{online}},\\
\hspace{2.5cm}Room:
TBD, or by appointment.\\
\textbf{TA}: TBD\\
\emph{Email}:
\href{mailto:tbd}{\color{gray}{tbd}}\\
\emph{Office Hour}: TBD, Room: TBD \\
\hspace{2.5cm}or by appointment. \\
}
\begin{syllabus}
\textbf{{\Large Overview and Course Goals}}\\
\vspace{-.2cm}
\lipsum[3-5]
\pagebreak
\lipsum[3-5]
\end{syllabus}
\end{document}
答案1
经过几次额外的尝试,我终于成功了!也许还有更好的代码,但它完成了任务。
\documentclass[PS,11pt]{syllabus}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{url}
\usepackage[small,compact]{titlesec}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{fancyhdr} % Added this package
\usepackage{graphicx} % Added this package
\usepackage[margin=1in,
headheight=25pt,
]{geometry}
% Reduce spacing between itemize
\let\tempone\itemize
\let\temptwo\enditemize
\renewenvironment{itemize}{\tempone\addtolength{\itemsep}{-.5\baselineskip}}{\temptwo}
% Roman section numbers
\renewcommand{\thesection}{\Roman{section}}
\usepackage[pdftex, bookmarksopen=true, bookmarksnumbered=true,
pdfstartview=FitH, breaklinks=true, urlbordercolor={0 1 1}, citebordercolor={0
1 0}, colorlinks = true]{hyperref}
% To eliminate the newline after \subsubsection
\titleformat{\subsubsection}[runin]{}{}{}{}[]
% Shade within enumerate
\usepackage[framemethod=TikZ]{mdframed}
\newmdenv[backgroundcolor=gray!40,roundcorner=10pt,nobreak=true]{shaded}
% Dot after section number
\titlelabel{\thetitle.\quad}
\textheight 9in
\textwidth 6.5in
\topmargin -.5in
\oddsidemargin 0in
\evensidemargin 0in
\newcommand{\percent}{\ensuremath{\%\;}}
% Header and Footer configuration
\fancypagestyle{syllabusstyle}{
\fancyhf{} % Clear all header and footer fields
\renewcommand{\headrulewidth}{0pt}
\fancyhead[R]{\includegraphics[height=1cm]{logo_ufpe.png}}
%%% % Added image to the header
\fancyfoot[L]{\emph{Professor}}
\fancyfoot[C]{\emph{Quarter}}
\fancyfoot[R]{\thepage} % Added page number in the right footer
}
\pagestyle{syllabusstyle}
\fancypagestyle{plain}{
\fancyhf{} % Clear all header and footer fields
\renewcommand{\headrulewidth}{0pt}
\fancyhead[R]{\includegraphics[height=1cm]{logo_ufpe.png}} %
%Added image to the header
\fancyfoot[L]{\emph{Professor}}
\fancyfoot[C]{\emph{Quarter}}
\fancyfoot[R]{\thepage} % Added page number in the right footer
}
\fancypagestyle{firststyle}
{
\fancyhf{}
\rhead{\raisebox{-2.2\height}{\includegraphics[height=30mm]{logo_ufpe.png}}}
}
\usepackage{graphicx,eso-pic}
% lipsum provides: \lipsum
% mwe provides: example-image
% graphicx provides: \includegraphics
% eso-pic provides: \AddTo..., \AtStockUpperLeft
\newlength\headpicwd
\newlength\headpicht
\setlength{\headpicwd}{10mm}% image width of physical page?
\setlength{\headpicht}{1.7cm}
\newcommand\printpic{%
\AddToShipoutPictureBG*{%
\AtStockUpperLeft{%
\raisebox{-\headpicht}{%
% centred with respect to physical page ..?
\hspace*{\dimexpr 0.73\pdfpagewidth - 0.5\headpicwd\relax}%
\includegraphics[width=\headpicwd,
height=\headpicht]{logo_ufpe.png}%
}%
}%
}%
}
\begin{document}
% print logo
\printpic
\title{\textbf{Course Title} \\
\vspace{.2cm}
Syllabus}
\name{Professor\\
\vspace{.2cm}Year}
\businessAddress{\emph{Room}: TBD \\ \emph{Time}: Tuesday/Thursday
5:00-6:20pm\\
\emph{Prerequisites}: None
}
\homeAddress{
\emph{Email}:
\href{mailto:[email protected]}{\color{gray}{[email protected]}}\\
\emph{Office Hour}: Thu 11:00am-Noon, sign up
\href{TBD}{\color{gray}{online}},\\
\hspace{2.5cm}Room:
TBD, or by appointment.\\
\textbf{TA}: TBD\\
\emph{Email}:
\href{mailto:tbd}{\color{gray}{tbd}}\\
\emph{Office Hour}: TBD, Room: TBD \\
\hspace{2.5cm} or by appointment. \\
}
%\thispagestyle{firststyle}
\begin{syllabus}
\textbf{{\Large Overview and Course Goals}}\\
\vspace{-.2cm}
\lipsum[3-5]
\pagebreak
\lipsum[3-5]
\pagebreak
\lipsum[3-5]
\end{syllabus}
\end{document}