TeXnik - Tips TeX and LaTeX

Welcome to the TeXnik website (under construction)

Miscellaneous Tips
TUG logo

Main page

Search CTAN:


Google c.t.t.

Google d.c.t.t.



addcontentsline - command | 
Barcode |  Border around each Page | 
circle with a letter in it |  Classfiles |  Color config file |  Current Time |  C++ - Symbol | 
Dashed underline |  Define a new Environment |  DNA-Sequences |  Dotted underline |  Double columnseprule |  Draft Option |  Drawing Math functions | 
Empty page |  Environment |  Environment in an environment (amsmath) |  epigraph-package | 
First Letter bold |  First Word in other fontsize | 
Graphics config file | 
Harpoon-Symbol |  hrulefill | 
Information about the (La)TeX System | 
jobname | 
LaTeX Length |  LaTeX System |  LaTeX Length | 
Mathcommands in textmode |  Motto on chapter-pages | 
\newenvironment | 
Overbracket |  Overwriting Images |  Overwriting Text | 
Package options |  Parameters in Environments |  Parsing filename |  Path-setting |  Picture on chapter-page |  Plot Math functions |  pstricks package | 
\raisebox Command |  \renewcommand{...} | 
Spanish Language |  Side by Side Example | 
Tally Symbol |  TeX System |  Time |  Timestamp |  twocolumn mode | 
Underbracket |  underscore | 
Width of an Image | 
xleft/rightharpoon-Symbol |  xypic and babel | 

Empty page

An empty page with a correct header and footer:

Without header and footer, but correct page counting:
  \thispagestyle{empty}% oder \pagestyle{empty}
A "real" empty page, without influencing the counter:


Modifying hrulefill

It is easy to modify the position and the width of the rule.

Parsing filename

Pass options to a package

When there are some problems with passing options to a package one can still use:
or from the command line
latex "\PassOptionsToPackage{dvips}{pict2e}\input{myfile}"
and when myfile loads pict2e without any specific options, the options on the command line will get used.

Stripping a prefix/suffix from a string

In the following example everything before the colon and itself is stripped. It is no problem to strip the suffix of the string instead of the prefix.


Put the code for a new environment into Layout->Preamble
	code for \begin{name}%
	code for \end{name}%
Using a parbox or a minipage requires some special code, f.ex.:
% put here additional stuff
% put here additional stuff
In your text use it in the usual way:
	any stuff

Side by Side Example

The package fancybox contains an environment for a "side by side example", which means on the left the code and on the right the output. This works well, but doesn't support umlauts or another special character. Here is a solution with package listings. sideBySideExample.png

\raisebox - command

xypic and babel
The xy-package redefines the catcode for " which causes problems with babel. So still use it in the following way:
% xypic stuff

addcontentsline - command
If you want to add more than one line to one of the toc/lot/... use
  line 1\hspace*{\fill}\endgraf
  line 2%
For the addtocontents -command see also here
Information about the installed (La)TeX System
If you need some information about your local TeX system try the following commands to get information about teTeX, TeX Directory Structure and pathsettings:
voss@shania:/tmp> texdoc TETEXDOC  (creates and opens a pdf document)
voss@shania:/tmp> texdoc tds  (creates and opens a pdf document)
voss@shania:/tmp> less `kpsewhich texmf.cnf`  (opens the configuration file)
voss@shania:/tmp> kpsewhich '-expand-var=$HOMETEXMF'

voss@shania:/tmp> kpsewhich '-expand-var=$HOMETEXMF'
voss@shania:/tmp> kpsewhich -expand-var=\$TEXMF

voss@shania:/tmp> kpsewhich -expand-var=\$TEXINPUTS
The last one prints the root of the TeX tree.

This one tells you where LaTeX search for tex or bib files

voss@shania:/tmp> kpsepath tex

voss@shania:/tmp> kpsepath bib
  • To get all valid options write kpsepath.
  • For document internal path settings go here

  • Command Characters / Underscore
    In LaTeX the characters $ % { } & # _ ^ are command characters and have to be escaped when you want to use them as normal characters:
    \$ \% \{ \} \& \# \_ \^
    otherwise you'll get an error at the LaTeX run.

    For the underscore there exists a special package underscore.sty. If you want to pass for example a filename with a underscore to another macro, then do it in the following way:

    \newcommand{\myMacro}[1]{something ... \includegraphics{#1}}
    For a document which has bookmarks with a underscore it is a bit different:

    C++ - Symbol


    Parameter in an Environment

    If you want to use a parameter in the closing part of an environment, than first define a dummy command. For example:

    Width of an Image

    in latex preamble

    Now you are able to place an image in a parbox with the right width.

    Path for files

    in latex preamble for files


    For the graphi files you can define:

    but remember:
  • you can't have an absolute path as an argument!
  • for a global, TeX system wide path setting go go here.

  • draft-Option
    In some cases it makes sense when LaTeX shows problematic formatting with vertical margin rules and the graphics as empty rectangles in the dvi-output. In this case choose the option draft for the documentclass.

    If you want to use this option for own commands like notes, than you can use this option and output some notes only when the draft option is set. The following example shows this for the arcticle class:

    The draft-option is passed to all other used packages. If you only want to mark the overfull lines then you can write
    instead of using the draft-option with all other effects.

    Overwriting text
    Use package soul.sty or try the following commands. Overwriting like is possible with command \myOverwrite{demo}{xxxxx}, which is defined in LaTeX-preamble
    \newcommand\myOverwrite[2]{\makebox[0cm][l]{#1}#2\ } 
    You can also define your own math-symbols:


    circle with letter in it
    \kreis{u} prints a circle with an u in it.

    Mathcommands in textmode
    If you are tired of writing some math-commands in mathmode, while they can't be written in textmode, like $\delta$, you can redefine these commands:
    \usepackage{xspace} %for a better layout
    Now you can write only \delta, LaTeX uses it by default as a math-command like:
    \delta and $delta$ is exactly the same ...



    See also the PSTricks package pst-barcode.

    Environment in an environment
    You cannot create a new environment which uses a given amsmath environment. With the following amsmath macro it is possible.

    local time: Sat Dec 9 12:09:21 CET 2023 ; file is: 1626.70994212963 days old
    contact webmaster _at_ TeXnik.de