다른 경로의 데이터에서 LaTeX 템플릿 만들기

다른 경로의 데이터에서 LaTeX 템플릿 만들기

나는 하나의 .tex 파일을 수정하고 네트워크에서 다양한 '상용구'(즉, 변경되지 않는 정보)를 가져올 수 있는 템플릿을 만들고 싶습니다. 첫째, 사용자가 새 폴더에 복사/붙여넣고 몇 가지 항목을 지정하는 .tex가 있습니다.

%% User Data
hello world!

%% Initialize document
\input{boilerplate/Preamble} %<----This folder would be located like C://User/etc,...

그런 다음 템플릿 폴더 내에서 서문을 가져오고 나머지 정보도 가져옵니다.

%% Select class
\documentclass[10pt]{article}

%% Packages
\usepackage{cmap}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{setspace}
\usepackage{siunitx}
\usepackage{lastpage}
\usepackage{newtxmath}
\usepackage{newtxtext}
\usepackage{textcomp}
\usepackage{longtable}
\usepackage{footnote}
\usepackage{multirow}
\usepackage{amssymb,amsmath,mathtools}
\usepackage{graphicx}
\usepackage[final]{pdfpages}
\usepackage{csvsimple}
\usepackage{grffile}
\usepackage{booktabs}
\usepackage[justification=centering]{caption}
\usepackage{longtable}
\usepackage{xcolor}
\usepackage{enumitem}
\setenumerate[1]{label=\thesection.\arabic*.}
\setenumerate[2]{label*=\arabic*.}
\usepackage[hyphens]{url}
\usepackage{breakurl} 
\usepackage[bookmarksnumbered]{hyperref}
\hypersetup{%
colorlinks=true,% hyperlinks will be coloured
citecolor=blue, % hyperlink text will be blue  
linkcolor=blue,% hyperlink text will be blue
linkbordercolor=blue,% hyperlink border will be blue
filecolor=blue,
urlcolor=blue,
breaklinks = true,
hypertexnames=true,
}
\usepackage[nameinlink]{cleveref}

%% Begin Document
\begin{document}
\input{boilerplate/Introduction} % Need path
\input{boilerplate/DetailedEquipmentInformationandRequirements} % Need path
\input{boilerplate/ProductInformation} % Need path
\input{boilerplate/SupplierScopeofWork} % Need path
\appendix
\include{boilerplate/Appendices} % Need path
\end{document}

내가 구상하는 폴더 구조는 다음과 같습니다.

Template
-Boilerplate
--Introduction.tex
--DetailedEquipmentInformationandRequirements.tex
Project 1
-Compiler 1 .tex file
-Image Folder
Project 2
-Compiler 2 .tex file
-Image Folder

보시다시피, Preamble을 호출한 다음 동일한 폴더에 없는 다양한 데이터를 호출해야 합니다. 이러한 정보를 불러오는 쉬운 방법이나 더 나은 관리 시스템을 아는 사람이 있습니까?

답변1

이는 보조 파일이 포함된 새로운 로컬 패키지 또는 클래스처럼 들립니다.

먼저, 개인 로컬 texmf 트리(당신이 유일한 사용자인 경우) 또는 사이트 전체 로컬 texmf 트리에 디렉토리를 생성하거나 mytemplate사람들이 설치해야 하는 지침과 함께 최종 템플릿을 zip 아카이브로 배포합니다. PC(개인 또는 사이트 전체의 texmf-tree)에 저장합니다. 제 경우에는 Linux에서 mytemplate다음 중 하나로 디렉토리를 생성합니다.

$(kpsewhich -var TEXMFHOME)/texmf/tex/latex/mytemplate

또는 다음과 같이 사이트 전체에 액세스하려면

$(kpsewhich -var TEXMFLOCAL)/tex/latex/mytemplate

이 폴더에 넣은 내용은 명시적인 경로 없이도 찾을 수 있습니다. 사이트 전체 로컬 디렉터리는 일반적으로 색인이 생성되므로 디렉터리에 파일을 추가한 후 색인을 다시 작성해야 합니다. Linux에서는 texhash루트(관리자)로 호출합니다.

공통 서문 및 문서 설정은 스타일 파일이 됩니다 mytemplate.sty. 또는 로드된 문서 클래스를 제어해야 하는 경우클래스 파일mytemplate.cls. 그런 다음 \documentclass{mytemplate}( 참조 mytemplate.cls) 또는 \documentclass{anyclass}\usepackage{mytemplate}( 참조 ) 을 사용하여 특정 문서를 시작합니다 mytemplate.sty.

특정 사용자 데이터는 나중에 사용하기 위해 저장하는 명령을 사용하거나 이를 즉시 처리하는 명령에 대한 매개변수로 수집할 수 있습니다. 첫 번째 접근 방식의 경우 LaTeX의 \author명령을 모델로 사용합니다.

\newcommand\@data{} % if it is ok that no data is provided
% or alternatively
\newcommand\@data{\@latex@warning@no@line{No \noexpand\data given}} % gives a warning if the data is needed but has not provided
\newcommand\data[1]{\renewcommand\@data{#1}} % Store the argument under the name `\@data`

문서에 가 포함되어 있으면 \data{42}나중에 스타일 또는 클래스 파일의 값에 \@data.

두 번째 접근 방식에서는 문서가 매크로를 호출 \processdata{42}하고 데이터가 즉시 처리됩니다.

텍스트 조각과 관련하여 포함할 직접 TeX 코드로 제공할 수 있습니다. 그러면 문서에 한 줄이 있습니다.

\input{myintroduction}

texmf-tree에 있는 경우 myintroduction.tex전체 경로를 제공하지 않고도 찾을 수 있습니다. 또는 mytemplate.cls또는 특정 작업을 수행하고 소개 텍스트를 그대로 포함하거나 명령문 자체를 사용하는 mytemplate.sty명령(일부 매개변수 포함)을 제공할 수 있습니다 .\Introduction\input

관련 정보