I suggest to enhance the code formatting with an optional argument for a filename.
===test.tex===
\documentclass{}
\begin{}
\end{}
Nice workaround suggested in comments to use 3 #:
test.tex
\documentclass{}
\begin{}
\end{}
I suggest to enhance the code formatting with an optional argument for a filename.
===test.tex===
\documentclass{}
\begin{}
\end{}
Nice workaround suggested in comments to use 3 #:
\documentclass{}
\begin{}
\end{}
In most cases, the specific name of a file doesn't matter, but even if it does, there's no need for a heading outside of the code. If the file name does matter, there usually are several files involved with one main file accessing the other(s) (e.g. a .bib file). In those cases, I'd recommend using a filecontents
environment in order to enable user to create everything with one file. If you complement that with the \jobname
macro, which carries the current file's name, you enable users here to have maximal influence on the names of files while still being able to refer to files. Example:
\documentclass{article}
\usepackage{biblatex}
\begin{filecontents}{\jobname.bib}
@book{one,
author = {Anthony Apple},
title = {Title}}
@book{two,
author = {Barbara Banana and Chris Coconut},
title = {Title}}
@book{three,
author = {Donna Date and Eric Eggplant and Fred Fig},
title = {Title}}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
You can also do things like \begin{filecontents}{\jobname-hello-world.tex}
. Here is some more information about the filecontents
environment and the filecontents
package (which might be handy in some cases), quoted from the filecontents
documentation:
The environment
filecontents
is intended for passing the contents of packages, options, or other files along with a document in a single file. It has one argument, which is the name of the file to create. If that file already exists (maybe only in the current directory if the OS supports a notion of acurrent directory' or
default directory') then nothing happens (except for an information message) and the body of the environment is bypassed. Otherwise, the body of the environment is written verbatim to the file name given as the first argument, together with some comments about how it was produced. The environment is allowed only before\documentclass
to ensure that all packages or options necessary for this particular run are present when needed. The begin and end tags should each be on a line by itself. There is also a star-form; this does not write extra comments into the file.(The comment about
filecontents
being valid only before\documentclass
is, in fact, untrue.filecontents
is allowed anywhere in the document's preamble.)The
filecontents
package provides a hacked-up version of thefilecontents
andfilecontents*
environments that lifts the two restrictions stated above, namely that existing files are never overwritten and thatfilecontents
must be used before the\documentclass
declaration (really, the\begin{document}
).filecontents
is therefore a more convenient way to write external files from within a LaTeX document than is provided by default by the LaTeX2ε kernel.
### test.tex
to create an headline 3rd order for the filename. – Martin Scharrer♦ Nov 7 '12 at 14:18