Latex Sty
⚡ ALL INFORMATION CLICK HERE 👈🏻👈🏻👈🏻
Latex Sty
Sign up or log in to customize your list.
more stack exchange communities
company blog
Stack Overflow for Teams
– Start collaborating and sharing organizational knowledge.
Create a free Team
Why Teams?
Asked
11 years, 11 months ago
Modified
2 years, 4 months ago
678 1 1 gold badge 5 5 silver badges 7 7 bronze badges
Highest score (default)
Trending (recent votes count more)
Date modified (newest first)
Date created (oldest first)
35.3k 41 41 gold badges 190 190 silver badges 263 263 bronze badges
302 4 4 silver badges 13 13 bronze badges
1,979 16 16 silver badges 28 28 bronze badges
6,199 2 2 gold badges 31 31 silver badges 34 34 bronze badges
Stack Overflow
Questions
Help
Products
Teams
Advertising
Collectives
Talent
Company
About
Press
Work Here
Legal
Privacy Policy
Terms of Service
Contact Us
Cookie Settings
Cookie Policy
Stack Exchange Network
Technology
Culture & recreation
Life & arts
Science
Professional
Business
API
Data
Accept all cookies
Customize settings
Find centralized, trusted content and collaborate around the technologies you use most.
Connect and share knowledge within a single location that is structured and easy to search.
I use some .sty-files that are not part of texlive and want to have them in a subdirectory of the folder with my main.tex. I used the following line to load the package:
This works, but compiling the main.tex with xelatex and using rubber gives me a warning:
Is there a way to prevent this warning or handle this case without having to include "sty\" in all .sty-files' \ProvidesPackage command or set the TEXINPUTS environment variable (which seems not to be possible from the main.tex itself)?
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
talks about precisely the same thing: so it seems, the only alternatives are either using TEXINPUTS environment variable; or using the import package . ( note, there is a variant on the import package on ...Including tex files pg 3. )
EDIT: I hoped that one could set the TEXINPUTS path directly in the tex file ( by using \write18 -- and note, some versions of LaTeX use --enable-write18 , mine uses -shell-escape to enable \write18 ; see also this ) - but it seems it is not possible:
" ... This isn't possible. ... The environment variable of the child process is set, but this hasn't an effect to its parent process (TeX). " ( Re: Setting the environmental variable TEXINPUTS within latex - comp.text.tex ).
... so, now I just call pdflatex in my Linux bash like this:
TEXINPUTS=.//:$TEXINPUTS pdflatex ./myfile.tex
and then it will resolve directly \usepackage{mypackage} in the myfile.tex file - even if mypackage.sty is in a subdirectory, say ./subdir/mypackage.sty .
As you discovered, putting the package in a subdirectory (say, ./sty/prettythesis.sty with respect to your main .tex file at ./ ), and calling the package via
will successfully load the package, but it will produce the warning
If all you want is to get rid of this warning, and you're OK with minor modifications in the .sty file, then you can simply change the package name that it reports, by changing the \ProvidesPackage command to
This can be inconvenient if you're going to be moving it around loads, but the modifications load isn't too bad either.
Even better, if what you have in there is a specific, modified version of a standard TeX package (like, say, this patch of natbib ), then the change in the package name clearly indicates what package it's providing, and if you reuse the file then it will (most likely) re-raise a warning to prompt you into making sure that you know what you're doing.
You can do it in your TeX file without changing your system's environment (do not forget the trailing slash / with each directory):
This way, though, may be not recommended for portability. As other answers mention, the "correct" way is to set the TEXINPUTS variable in your system environment before you call latex; in Windows it is (you can place it in a batch file):
Simply put line below before the call to pdflatex (or latex) in your makefile or build script:
Thanks for contributing an answer to Stack Overflow!
By clicking “Post Your Answer”, you agree to our terms of service , privacy policy and cookie policy
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
Site design / logo © 2022 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2022.9.9.42970
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy .
0.291 2018.10.03 20:42:04 字数 1 180 阅读 21 384
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{minimal}[1995/10/30 Standard LaTeX minimal class]
\renewcommand{\normalsize}{\fontsize{10pt}{12pt}\selectfont}
\setlength{\textwidth}{6.5in}
\setlength{\textheight}{8in}
\pagenumbering{arabic} % needed even though this class will
% not show page numbers
Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
passiontim 阅读 165 654 评论 24 赞 701
1、通过CocoaPods安装项目名称项目信息 AFNetworking网络请求组件 FMDB本地数据库组件 SD...
转至元数据结尾创建: 董潇伟,最新修改于: 十二月 23, 2016 转至元数据起始第一章:isa和Class一....
最近 正想着 提笔写点生活 记录呢 可真是有点“瞌睡了找到枕头”的感觉哦,希望这个APP可以记录下我心情的点点滴滴…
2016年,于我而言是一个蛮特别的年份。 在慌慌张张中就度过了大学的第一年,晋升为校园里最年轻的一辈学长;连任课老...
缓缓睁开眼,只见冷冻维生舱缓缓打开。到地球了吗?我想没有。一位舰员朝我走来,向我敬了个军礼。 “睡...
人们常说陪伴是最长情的告白,漫漫长路有你的陪伴,感觉真好。 我时常会想到以后生活的场景,陪着你吃完饭...
叫一声好人 你知道吗 六年前、您在医院里 帮助过一对老人家垫付过医药费 使得他们病情得到治疗 顺利出院 事后、您没...
一般来说, .cls 和 .sty 文件都是增加 LaTeX 功能的补足文件。它们在我们排版文章是时对应的使用 \documentclass{} 和 \usepackage{} 加载,在包内部则对应的使用 \LoadClass,\LoadClassWithOptions 和 \RequirePackage,\RequirePackageWithOptions 加载。我们通常将 .cls 文件称之为类(classes)文件,将 .sty 文件称之为风格(style)文件或者包(package)。
虽然它们都可以包含任意的 TeX 和 LaTeX 代码,但是它们的使用方式不同。我们必须通过 \documentclass 加载一个类文件,并且在一个 LaTeX 文件中只能出现一次,通常也是第一个出现的命令。而另一方面,包是一个可选项,它可以根据我们的需求加载任意多个(在开始文档之前)。
什么时候编写一个类文件?什么时候编写一个风格文件?或者说什么命令应该放到 .cls 文件?什么命令应该放到 .sty 文件中呢?一个经验法则是:
如果一个命令是用来控制文档结构的,则应该放到类文件中;否则应该放到包文件中。
如果一个命令可以被其他所有的文档使用,那么将这个命令放置到一个包中;如果不是,则将它放到一个类文件中。
当一个命令使上述两条规则冲突的时候,优先考虑第一条规则。如 \section 命令几乎在所有的文档中都使用,但因为其是用来控制文档结构的,我们将其放置到类文件中。
一般情况下,类文件主要分为两个部分:一种是标准类文件,如: article,report 或者 letter ;另一种是基于标准类文件的扩展文件,如基于 article 的 proc 文件类。当然我们也可以不基于任何标准类编写全新的类文件,通常这比较复杂,需要我们重新定义大量常用的命令,因此不建议这么做。
额外说明:如果我们要自己定义一个不基于标准类的类文件,应确保至少包含以下四个部分:定义 \normalsize 命令,设置 \textwidth,\textheight 的值以及设置页编码方式.下面给出一个最小类文件的例子,当然对于大部分类其包含的命令是远远多于以下类文件的:
对于包,或者说是风格文件,它用来提供所有其他类文件不提供的命令。它们广义上被分为两类:对类文件进行修正,或者添加额外功能。
例如 graphicx 包提供包含图像的方法和将所有图形效果应用到文档元素中。这个包本质上可以应用到所有类文件上。另一个例子—— sectsty 包。该包提供了方法用来自定义标准类文件( article,report,book )中的段落开头(section headers)。所以,如果试图将它和 memoir 包一起使用,将导致它重写 memoir 的创建段落开头的方法,进而导致出现严重错误。
.cls 和 .sty 文件都可以使用 LaTeX 中的任意代码以提供一些功能和命令。类文件一般用来控制文档的结构并提供该类特有的命令,如段落命令、字体命令、特定的页眉页脚设置等。包文件用来提供其他的所有的功能和命令。
大部分情况下我们应该考虑将我们的命令放置到包中,这样我们可以根据需求任意的选择是否加载这些包。如果我们真的需要编写类文件,应该基于现有的标准类文件进行编写,这样可以节省我们很多命令的定义(如上面提到的 section 命令以及其他常用的字体选择命令)。同时类文件的内容不宜过多,当我们类文件的内容过多时,我们应该考虑是否将其中部分命令单独提取出来作为一个包。
\NeedsTeXFormat { LaTeX2e }
\ProvidesPackage { examplepackage } [2014/08/24 Example LaTeX package]
\NeedsTeXFormat { LaTeX2e }
\ProvidesPackage { examplepackage } [2014/08/21 Example package]
\RequirePackage { imakeidx }
\RequirePackage { xstring }
\RequirePackage { xcolor }
\definecolor { greycolour }{ HTML }{ 525252 }
\definecolor { sharelatexcolour }{ HTML }{ 882B21 }
\definecolor { mybluecolour }{ HTML }{ 394773 }
\newcommand { \wordcolour }{ greycolour }
\NeedsTeXFormat { LaTeX2e }
\ProvidesPackage { examplepackage } [2014/08/21 Example package]
\RequirePackage { imakeidx }
\RequirePackage { xstring }
\RequirePackage { xcolor }
\definecolor { greycolour }{ HTML }{ 525252 }
\definecolor { sharelatexcolour }{ HTML }{ 882B21 }
\definecolor { mybluecolour }{ HTML }{ 394773 }
\newcommand { \wordcolour }{ greycolour }
\DeclareOption { red }{ \renewcommand { \wordcolour }{ sharelatexcolour }}
\DeclareOption { blue }{ \renewcommand { \wordcolour }{ mybluecolour }}
\DeclareOption* { \PackageWarning { examplepackage }{ Unknown ‘ \CurrentOption ’ }}
\ProcessOptions\relax
\NeedsTeXFormat { LaTeX2e }
\ProvidesPackage { examplepackage } [2014/08/21 Example package]
\RequirePackage { imakeidx }
\RequirePackage { xstring }
\RequirePackage { xcolor }
\definecolor { greycolour }{ HTML }{ 525252 }
\definecolor { sharelatexcolour }{ HTML }{ 882B21 }
\definecolor { mybluecolour }{ HTML }{ 394773 }
\newcommand { \wordcolour }{ greycolour }
\DeclareOption { red }{ \renewcommand { \wordcolour }{ sharelatexcolour }}
\DeclareOption { blue }{ \renewcommand { \wordcolour }{ mybluecolour }}
\DeclareOption* { \PackageWarning { examplepackage }{ Unknown ‘ \CurrentOption ’ }}
\ProcessOptions\relax
%%Numbered environment
\newcounter { example } [section]
\newenvironment { example } [1][] { \refstepcounter { example } \par\medskip
\noindent \textbf { My~environment~ \theexample . #1 } \rmfamily }{ \medskip }
%%Important words are added to the index and printed in different colour
\newcommand { \important } [1]
{ \IfSubStr { #1 }{ ! }
{ \textcolor { \wordcolour }{ \textbf { \StrBefore { #1 }{ ! } ~ \StrBehind { #1 }{ ! }}} \index { #1 }}
{ \textcolor { \wordcolour }{ \textbf { #1 }} \index { #1 } \kern -1pt }
}
\documentclass { article }
\usepackage [utf8] { inputenc }
\usepackage [red] { examplepackage }
\makeindex
\title { Package Example }
\author { Team Learn ShareLaTeX }
\date { }
\begin { document }
\maketitle
\section { Introduction }
In this document a new package is tested. This package allows special numbered
environments
\begin { example }
This text is inside a special environment, some boldface text is printed
at the beginning and a new indentation is set.
\end { example }
Also, there's a special command for \important { important!words } that will be
printed in a special \important { colour } depending on the parameter used in the
\important { package } importation statement. Because it's \important { important } .
\printindex
\end { document }
\usepackage [red] { examplepackage }
We only use cookies for essential purposes and to improve your experience on our site. You can find out more in our cookie policy .
Essential cookies only Accept all cookies
Sometimes the best option to use your own commands and macros in a document is to write a new package from scratch. This article explains the main structure of a new package.
The first thing to do before coding a new package is to determine whether you really need a new package or not. It's recommended to search on CTAN (Comprehensive T e X Archive Network) and see if someone already created something similar to what you need.
Another important thing to have in mind is the difference between packages and classes . Making the wrong choice can affect the flexibility of the final product.
The structure of all package files can be roughly described in the next four parts:
In the next subsections a more detailed description of the structure and a working example, examplepackage.sty , will be presented.
There are two simple commands that all packages must have:
The command \NeedsTeXFormat{LaTeX2e} sets the L a T e X version for the package to work. Additionally, a date can be added within brackets to specify the minimal release date required.
The command ProvidesPackage{examplepackage}[...] identifies this package as examplepackage and, inside the brackets, the release date and some additional information is included. The date should be in the form YYYY/MM/DD
Most of the packages extend and customize existing ones, and also need some external packages to work. Below, some more code is added to the sample package "examplepackage.sty".
The commands in this part either initialize some parameters that latter will be used to manage the options, or import external files.
The command \RequirePackage is very similar to the well-known \usepackage , adding optional parameters within brackets will also work. The only difference is that the \usepackage can not be used before \documentclass command. It's strongly recommended to use \RequirePackage when writing new packages or classes.
To allow some flexibility in the packages a few additional options are very useful. The next part in the file "examplepackage.sty" handles the parameters passed to the package-importing statement.
Below a description of the main commands that can handle the options passed to the package.
The command \DeclareOption{}{} handles a given option. It takes two parameters, the first one is the name of the option and the second one is the code to execute if the option is passed.
The command \OptionNotUsed will print a message in the compiler and the logs, the option won't be used.
The command \Declareoption*{} handles every option not explicitly defined. It takes only one parameter, the code to execute when an unknown option is passed. In this case it will print a warning by means of the next command:
\PackageWarning{}{} . See handling errors for a description about what this command does.
\CurrentOption stores the name of the package option being handled at a determined moment.
The command \ProcessOptions\relax executes the code fore each option and must be inserted after all the option-handling commands were typed. There's a starred version of this command that will execute the options in the exact order specified by the calling commands.
In the example, if the options red or blue are passed to the \usepackage command within the document, the command \wordcolor is redefined. Both colours and the default grey colour were defined in the preliminary declarations after importing the xcolor package.
In this part most of the commands will appear. In "examplepackage.sty". Below you can see the full package file.
This package defines the new environment example , and a new command \important , that prints the words in a special colour and adds them to the index.
To fully understand each command see the reference guide and the links in the further reading section .
Below, a document that uses the package examplepackage.sty .
When it comes to develop new packages it's important to handle possible errors to let know the user that something went wrong. There are four main commands to report errors in the compiler.
List of commands commonly used in packages and classes
Have you checked our knowledge base ?
Message sent! Our team will review it and reply by email.
D Incest
Brunette Babe Lisa Ann Finds A Gloryhole
Men Porn Cartoon