Hot answers tagged

57

\graphicspath comes from LaTeX's \input@path, just using the paths for graphics files. \input@path can be set independently, e.g.: \makeatletter \def\input@path{{path1/}{path2/}} \makeatother Internally package graphics stores its path of \graphicspath in \Ginput@path and locally sets \input@path to \Ginput@path, if it looks for files via \IfFileExists. ...


47

Edit: There is now LaTeX package for testing https://github.com/michal-h21/odsfile Before I post it on CTAN, any comments on style/grammar/spell in the documentation files, as well comments on the source code, are highly welcome. There is solution using luatex's zip library and pure lua xml processing library LuaXML, which you should install to same ...


33

In addition to listings, the fancyvrb package is equally suitable for this purpose. This package provides the \VerbatimInput command (similar to \verbatiminput), which can be customised using various parameters (e.g., reducing font size). \documentclass{article} \usepackage[dvipsnames]{xcolor} \usepackage{fancyvrb} % redefine \VerbatimInput \...


27

Use the package import, which does exactly one thing: to solve this problem. See http://www.ctan.org/pkg/import Basically the package defines two commands: \import and \subimport. \import needs an absolute path, while subimport needs a relative path. They both look at the current folder and TEXINPUTS first. If you want to avoid checking TEXINPUTS, use ...


27

Thanks to egreg. Adding \usepackage{verbatim} to the preamble, and using \verbatiminput{<file path>} to input, does the tick!


23

You provide several interpretations of what various commands do. \makeatletter and \makeatother are just necessary for redefining macros or something. Not quite. By default, the character @ is not allowed to occur in the name of a TeX or LaTeX macro; instead, valid multi-character macro names must consist of uppercase and lowercase letters exclusively ...


22

That's a pretty basic mechanism in (La)TeX which you can also use to "separate out" other parts of your document. Simply paste any number of lines into a new text file (say, file.tex) and then input it by putting \input{file} in the place where the lines used to be (note you can leave out the .tex extension). \input will act exactly like 'pasting' the ...


22

The journal's input requirements are very straightforward. To fix ideas, let's assume that your document consists of four files you created yourself: main.tex, sec1.tex, sec2.tex, and mybib.bib. mybib.bib may contain entries that are not cited in the body of the document. Let's also assume that you know to deploy \cite, \bibliographystyle, and \bibliography ...


21

Advantages It is a good trick, if someone wants to put TeX code before. Examples: pdflatex '\def\foo{bar}\input{filename}' pdflatex '\includeonly{introduction}\input{filename}' or inside \write18 (shell escape feature): \immediate\write18{\detokenize{pdflatex '\def\foo{bar}\input{filename}'}} \immediate\write18{\detokenize{pdflatex '\includeonly{...


19

Instead of using \@input the better method is probably to use \InputIfFileExists{file}{then}{else} This will run \input on file if it exists, and then execute the code in then. If the file does not exist, the code in else is executed. You could for example add a warning in the else part, just to inform you that this particular file was not found. If you ...


17

TeX only processes the input line by line, so there is a limit on the number of characters in a line, but not on the total size of the file. Your editor however probably does need to read the entire file into memory so may have limits on the file size. The editor I use warns if the file is more than 10MB but will open files larger than that, up to the ...


16

This is what has been working great for me for about two years now. create a .sty file containing your universal preamble. A .sty file, basically, is a regular TeX file starting with \ProvidesPackage{mystyle}, ending with \endinput, and everything else inbetween.*) in your Dropbox (or similar), create a directory named texmf-local, and a subdirectory such ...


16

Use the double quote symbol ". In this case, the file File Name.tex contained the words Hello World ... and Repin Painting.jpg contained, well, "Barge Haulers on the Volga" (Russian: Burlaki na Volge, Бурлаки на Волге), best viewed while listening to Lydia Salnikova perform Ah Ty Step Shirokaya http://www.broadjam.com/artists/songs.php?artistID=81353&...


14

I replaced your if-if-if-if construct with a simple \ifcase test. \moon works just fine now. Though the actual problem was another one. The counter assignments \global\advance\<counter> by 1 should be finished with a \relax. This also applies to the \ifnum but in this instance, it is not needed as math-mode is introduces right away. Without the \relax ...


14

One way is to use \read which reads a file a line at a time \documentclass{article} \newcounter{cnt} \newread\myread \openin\myread=numberfile \begin{document} \read \myread to \zz \setcounter{cnt}{\zz} \arabic{cnt} \end{document} assuming numberfile.tex looks like 33


14

Latex actually supports to use relative paths. Both of the following two ways can achieve your goal (assume all your figures in figures folder): Add \graphicspath {{figures/}} before \begin{document} Use \includegraphics[width=\textwidth]{figures/your-figure.eps}


14

There is no inconsistency. The \include command should have an argument that is a file name without extension; this is the documented behavior and is a requirement. The command is only meant for inputting .tex files in order to do “selective processing” of the material by means of \includeonly. On the other hand, \input can be used for any kind file (even ...


13

Here's how it goes in texlive (and presumably other web2c distros): The changefile tex.ch removes the Knuth definition of input_ln; The underscore gets lost in the conversion of web to c; The resulting C code #includes texmfmp.h which does #define inputln(stream, flag) input_line (stream) The function input_line() gets defined in texmfmp.c where the ...


13

You could use the -latex or -pdflatex options. I'll use pdflatex for the examples but it should work with latex as well. latexmk -pdf article will look for article.tex, invoke the command associated with the pdflatex option which by default is "pdflatex -interaction=nonstopmode -synctex=1 %S %O" where %S is replaced by the filename and %O by the options. ...


12

Here is an example showing the import of a higher-level file by a file in a subfolder, which is what I understood you want to achieve with the header file. A file chapter1.tex is located in a /subfolder. It loads two files: part1.tex, which is located in the same /subfolder, and partA.tex from the home folder. partA.tex also loads part1.tex; it therefore ...


12

If I understand your question correct, you want a file containing your preamble and you want to include it in every document. Then just put the parts of the preamble that are not document specific into a file and save that file somewhere in the LaTeX search path, e. g. $SOMETEXMFDIR/tex/latex/mypreamble/mypreamble.tex. You can get a list of valid values for $...


12

The following is written to accord to Mac OS Xs' FHS implementation. This is principally valid for any UNIX-like OS. Pdflatex allows you to specify complete paths: \input{/Users/user_name/some/path} Under Unix-Like systems you may even use shell(bash) variables in you paths: \input{$HOME/some/path} or common abbreviations \intput{\string~/some/path} (...


12

Quoting Kopka and Daly, Guide to LaTeX, 4th edition (2004), p. 207: \include commands may not be nested: They may only appear in the main processing file. However, an \input command may be given within a file that is \included.


12

You can use package catchfile to store the contents of a file in a macro: \documentclass[letterpaper,12pt]{article} \usepackage[pdftex,colorlinks=true,hidelinks]{hyperref} \usepackage{catchfile} \usepackage{trimspaces} \CatchFileDef{\GitHash}{contains_git_hash.txt}{} \makeatletter \trim@spaces@in\GitHash \makeatother \hypersetup{ pdftitle={A method ...


11

It's easy to see where the loop comes from as \Bigr is defined in terms of \Big which is (by default) \def\Big#1{{\hbox{$\left#1\vbox to11.5\p@{}\right.\n@space$}}} so defined in terms of \left It is probably safer just to do a replace/edit on the incoming file If you wanted to do this in TeX you'd neeed \let\oldleft\left \let\oldright\right and then ...


11

The enumitem package has an option to description: style=unboxed and thus the contents of \item[...] is then wrapped. One might also get away by redefining \descriptionlabel, though I don't think the broken line will be indented (I tend to like having them stand out, so when I use there very long titles I have the text start on the next line after the title.


11

Without a \read: \documentclass{article} \usepackage{catchfile} \newcommand{\setcounterfromfile}[2]{% #1 = counter, #2 = file name \CatchFileDef{\scfftemp}{#2}{\endlinechar=-1 }% \setcounter{#1}{\scfftemp}} \newcounter{cnt} \setcounterfromfile{cnt}{numberfile} \showthe\value{cnt} If numberfile.tex contains the only line 12345 (a very difficult ...


11

TeX has the \read and \write primitives for reading and writing to files plus of course \input for inputting an entire file 'here'. If you look at for example the LaTeX cross-ref mechanism is uses \write but avoids using \read (line-by-line) in favour of making use of \input with appropriately designed secondary files. As \input is easy enough to ...


11

I am sorry, arara limits the directive lookup scope to the current document. It would be quite challenging to detect special macros and process them accordingly, like following a file through \input, \include or similar streams. It is really by design. That's being said, I've been thinking of adding a new feature in the near future called metadirective. ...


10

The terminalblock environmnet is for code directly input; it doesn't make much sense to use \lstinputlistings inside this environment since it will be taken verbatim (although it could be done, for example, by escaping to LaTeX). A better approach is to define a style and use this style both for your environment (to be used to input direct code) and for \...


Only top voted, non community-wiki answers of a minimum length are eligible