Могу ли я написать файлы CLS в LaTex вместо TEX?

StackOverflow https://stackoverflow.com/questions/3702222

  •  02-10-2019
  •  | 
  •  

Вопрос

У меня есть какой -то код инициализации в файле Xelatex, который я хотел бы поместить в отдельный файл, чтобы я мог использовать его в будущих текстах. Какой самый быстрый способ преобразовать мой код xelatex в файл класса латекса?

Это было полезно?

Решение

Вы можете поместить свой код преамбулы в .cls файл, а затем используйте \documentclass{mydocstyle} загрузить его. Ваш .cls Файл будет выглядеть так:

% Declare that this document class file requires at least LaTeX version 2e.
\NeedsTeXFormat{LaTeX2e}

% Provide the name of your document class, the date it was last updated, and a comment about what it's used for
\ProvidesClass{mydocstyle}[2010/09/13 Bluetulip's custom LaTeX document style]

% We'll pass any document class options along to the underlying class
\DeclareOption*{%
  \PassOptionsToClass{\CurrentOption}{article}% or book or whatever
}

% Now we'll execute any options passed in
\ProcessOptions\relax

% Instead of defining each and every little detail required to create a new document class,
% you can base your class on an existing document class.
\LoadClass{article}% or book or whatever you class is closest to

% Now paste your code from the preamble here.
% Replace \usepackage with \RequirePackage. (The syntax for both commands is the same.)

% Finally, we'll use \endinput to indicate that LaTeX can stop reading this file. LaTeX will ignore anything after this line.
\endinput

Обратите внимание, что файлы класса документов могут стать намного сложнее (если вы хотите включить такие варианты, как \documentclass[option]{mydocstyle}, и т. д.), но этот базовый формат должен заставить вас начать.

Сохраните свой файл как mydocstyle.cls и поместите его в текущий каталог с вашим .tex файл.

Вы также можете взглянуть на Latex2e для класса и руководство по авторам пакетов. Анкет Это проведет вас более подробно.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top