我想为我的实验报告创建一个定制的“课程”

我想为我的实验报告创建一个定制的“课程”

我经常写化学实验报告。随着时间的推移,我弄清楚了要使用哪些包。但是,我想编写某种超类(例如在 C++ 中),以便以下代码在目录中读取,但不插入文件中。我将非常感激您重定向到正确的信息。谢谢!

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{setspace}

%Set the dimensions of the document
\usepackage[a4paper,margin=1in]{geometry}
\usepackage{graphicx, pgfplots, textcomp,lscape}


%Bibliography style and source
\usepackage{achemso}
\bibliographystyle{achemso}
\usepackage[backend=biber,sorting=none]{biblatex}
\addbibresource{./references.bib}
\usepackage{xstring}
\usepackage{xfrac}
\usepackage{changes}
\usepackage{titlesec}

%Image path directory
\graphicspath{{./images/}}

\usepackage[labelfont=bf]{caption}
\captionsetup{belowskip=10pt,aboveskip=10pt}

\usepackage{xstring}
\usepackage{indentfirst}

%Load math + SI packages
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{siunitx}

%Make cell space, scientific notation, and standard units
\usepackage{cellspace, booktabs}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}

\begin{document}
%setup graphics path

%Create the header file. Important: don't insert blank space between the minipage to get them aligned
\begin{minipage}[]{5cm}
\includegraphics[width=7cm]{Concordia_Logo2.png}
\end{minipage}
\begin{minipage}[]{10cm}
  \begin{flushright}
  Johnathan\\
  \underline{Student ID:} 123456\\
  Laboratory report \#4\\
  CHEM221\\
 \end{flushright}
\end{minipage}

\vspace{3em}
\centerline{\Large\textbf{Liquid-liquid extraction: purification of benzoic acid}}

\tableofcontents

\onehalfspacing
\begin{document}

\section{Introduction}

\end{document}

回复 cfr 的回答

编辑:@cfr 嗨!谢谢!!但是,当我执行以下操作时:

\RequirePackage{achemso}
\bibliographystyle{achemso}
%\RequirePackage[backend=biber,sorting=none]{biblatex}

我得到:\references.bib

在小页面顶部。好像没有读取references.bib(类似于biber),不是吗?谢谢!:)

答案1

像这样吗?

mypackage.sty

\ProvidesPackage{mypackage}
\RequirePackage[utf8]{inputenc}
\RequirePackage{setspace}

%Set the dimensions of the document
\RequirePackage[a4paper,margin=1in]{geometry}
\RequirePackage{graphicx, pgfplots, textcomp,lscape}

%Bibliography style and source
% \RequirePackage{achemso}% or comment out biblatex
% \bibliographystyle{achemso}
\RequirePackage[backend=biber,sorting=none]{biblatex}
\RequirePackage{xstring}
\RequirePackage{xfrac}
\RequirePackage{changes}
\RequirePackage{titlesec}

\RequirePackage[labelfont=bf]{caption}
\captionsetup{belowskip=10pt,aboveskip=10pt}

\RequirePackage{xstring}
\RequirePackage{indentfirst}

%Load math + SI packages
\RequirePackage{amsmath}
\RequirePackage{amssymb}
\RequirePackage{siunitx}

%Make cell space, scientific notation, and standard units
\RequirePackage{cellspace, booktabs}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}

\renewcommand*\maketitle{%
  \begin{minipage}[]{5cm}
    \includegraphics[width=7cm]{tiger}
  \end{minipage}
  \begin{minipage}[]{10cm}
    \begin{flushright}
      \@author\par
      \underline{Student ID:} \@studentid\par
      Laboratory report \#\@reportno\par
      \@classno\par
    \end{flushright}
  \end{minipage}
  \bigskip\par
  \begin{center}
    \Large\bfseries\@title
  \end{center}%
}
\newcommand*\@studentid{}
\newcommand*\@reportno{}
\newcommand*\@classno{}
\newcommand*\studentid[1]{\renewcommand*\@studentid{#1}}
\newcommand*\reportno[1]{\renewcommand*\@reportno{#1}}
\newcommand*\classno[1]{\renewcommand*\@classno{#1}}
\endinput

文档:

\documentclass[12pt]{article}
\usepackage{mypackage}
%setup graphics path
\addbibresource{./references.bib}% comment this line out if using achemso/BibTeX rather than Biblatex/Biber
%Image path directory
\graphicspath{{./images/}}
\title{Liquid-liquid extraction: purification of benzoic acid}
\author{Johnathan}
\studentid{123456}
\reportno{4}
\classno{CHEM221}
\begin{document}
\maketitle
\tableofcontents

\onehalfspacing

\section{Introduction}

\printbibliography% comment out for achemso/BibTeX
%\bibliography{references}% uncomment for achemso/BibTeX

\end{document}

相关内容