Undefined control sequence at first line of a document - latex

\documentclass{book}
\usepackage{amsmath}
\usepackage[german]{babel}
\usepackage{amssymb}
\usepackage{amsxtra}
\usepackage[dvips]{epsfig,psfrag}
\usepackage{listings}
\newcommand{\refchapter}[1]{Kapitel~\ref{#1}}
\newcommand{\refsec}[1]{Sektion~\ref{#1}}
\newcommand{\refeqn}[1]{Gleichung~(\ref{#1})}
\newcommand{\reffig}[1]{Abbildung~\ref{#1}}
\title{\bf Grundz\"uge der Softwareentwicklung \\
{\small Analyse- und Entwurfsdokument} \vspace{1cm}\\
\centering
\epsfig{file=figures/logo.eps,width=.4\textwidth}
}
\author{Uschi Musterfrau, Detlef Mustermann und Ralf Auchmustermann}
\date{Matr.-Nr. 0815, 0816 und 0817 \\
email: {\tt [uschi|detlef|ralf]#rwth-aachen.de}
}
\begin{document}
\lstloadlanguages{[ISO]C++}
\lstset{basicstyle=\small, numbers=left, numberstyle=\footnotesize,
stepnumber=1, numbersep=5pt, breaklines=true, escapeinside={/*#}{#*/}}
\pagestyle{headings}
\maketitle
\tableofcontents
\include{vorwort}
\include{analyse}
\include{entwurf}
\include{nutzerdoc}
\include{entwicklerdoc}
\bibliographystyle{plain}
\bibliography{analyse_entwurf}
\appendix
\include{quellcode}
\end{document}
this is how my file starts. I didn't even edit it, I received it like this. However, if I want to make a pdf, it gives me the undefined control sequence error at the first line... What is wrong??

My guess is that you're trying to use TeX instead of LaTeX. TeX won't recognize the \documentclass command. Make sure you use LaTeX.

It might be that one of the tools in your tool chain gets irritated by a Byte-Order Mark (BOM), which is a special Unicode character to indicate the endianness used in your file.
Unfortunately, a BOM may have unwanted side-effects.
You might try to save the file with another editor which won't add this mark in the beginning, or remove it with a hex editor.

try getting rid of \usepackage[dvips]{epsfig,psfrag} if you're using pdflatex.

Perhaps TeXshop doesn't recognize your file as a LaTeX file and runs it with plain TeX or ConTeXt. If you can post your logfile (the beginning) here, we can help you for sure.

Related

Undefined references using pagesel in Latex

Let's say I have some labels in a part of the document that I exclude using pagesel. However, I want to reference them in the part that I am including. How is that possible?
Below is a minimum example which should print "This is reference 1", but instead prints "This is reference ??".
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[files,2-]{pagesel}
\title{Pagesel problem}
\begin{document}
\maketitle
\section{Introduction}
This is label \label{ref:label1}.
\cleardoublepage
This is reference \ref{ref:label1}
\end{document}
You can retain the labels from pages not shown by first compiling your whole document without the pagesel package and then, in a second step, use the pagesel package with the default nofile option:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[
%files,
2-]{pagesel}
\title{Pagesel problem}
\begin{document}
\maketitle
\section{Introduction}
This is label \label{ref:label1}.
\cleardoublepage
This is reference \ref{ref:label1}
\end{document}
Other possible approach: compile the complete document and then use a tool like pdftk to extract the pages you like.

New to latex, don't know why this \maketitle command is showing error?

I am new to latex and trying to use a conference template. This error is popping up for the \maketitle command and I have tried many things which did no help:
l.72 \maketitle
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
Here is what I have in .tex file:
\begin{document}
\maketitle
%===============================================================================
\begin{abstract}
And here is where the .sty file has defined the \maketitle command:
% create title
\providecommand{\maketitle}{}
\renewcommand{\maketitle}{%
\par
\begingroup
\renewcommand{\thefootnote}{\fnsymbol{footnote}}
% for perfect author name centering
\renewcommand{\#makefnmark}{\hbox to \z#{$^{\#thefnmark}$\hss}}
% The footnote-mark was overlapping the footnote-text,
% added the following to fix this problem (MK)
\long\def\#makefntext##1{%
\parindent 1em\noindent
\hbox to 1.8em{\hss $\m#th ^{\#thefnmark}$}##1
}
\thispagestyle{empty}
\#maketitle
\#thanks
\#notice
\endgroup
\let\maketitle\relax
\let\thanks\relax
}
The generated Pdf looks just fine, but the error prevails. Please enlighten me, if you understand what is going on.

Bibtex wrongly compiles accent mark

I am attempting to compile my latex file and I have a source with author's last name with an accent mark (two dots above the letter o). In the preamble of my file, I have
\documentclass[twoside,11pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{textcomp}
\usepackage{listings}
\usepackage{xcolor, color}
\usepackage{graphics, graphicx, rotating}
\usepackage{float}
\usepackage[caption=false]{subfig}
\usepackage{algpseudocode, algorithm}
\usepackage{url, hyperref}
\usepackage{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
Then, at the end of the file, I have
\bibliographystyle{plain}
\bibliography{bib}
In the .bib file I have
#phdthesis{kon,
author = {K\"{o}n},
title = {TITLE}
year = {2014}
}
However, when I compile (I'm using TeXStudio), I get what you see in the image.
It doesn't seem to be recognizing that there are two quotes (' is highlighted in blue and then ' is highlighted in black in the IDE I'm using). I'm not sure how to get the correct accent mark. I can't seem to find this issue elsewhere, and there are no other ways in latex literature (that I can find). Thank you!
Code for .tex file:
\documentclass[twoside,11pt]{article}
\usepackage{jmlr2e}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{textcomp}
\usepackage{listings}
\usepackage{xcolor, color}
\usepackage{graphics, graphicx, rotating}
\usepackage{float}
\usepackage[caption=false]{subfig}
\usepackage{algpseudocode, algorithm}
\usepackage{url, hyperref}
\usepackage{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\begin{document}
Here is how it gets cited: \citep{konig2014}
\bibliographystyle{plain}
\bibliography{bibl}
\end{document}
Code for .bib file:
#phdthesis{konig2014,
author = {K\''{o}nig, R.},
title = {Enhancing genetic programming for predictive modeling},
school = {\''{O}rebro University},
year = {2014}
}
Since your edit, your .bib file shows \'' (backslash, single quote, single quote), which is wrong and results in the weird accents you're seeing: it's putting an acute accent (´, coded as \') on top of a single quote (', also coded as '). The correct syntax is \" (backslash, double quote).
If I write the .bib file in the program TeXworks, then \" (backslash, double quotes) automatically turns into \'' (backslash, single quote, single quote). Even if I compile my .tex file that references the .bib file in TeXstudio, I still get weird symbols as show in the image above, rather than the expected two dots above the o because TeXworks doesn't seem to recognize the double quotes. BUT if I write the .bib file in the TeXstudio program, then it compiles as expected. I'm not sure what's going on behind the scenes (maybe there is a setting I have to change?), but the issue was TeXworks, not the \"{o}.
Thanks all for your help!

Temporarily changing document class in LaTeX/resetting pdfLaTeX

How can I temporarily cause pdfLaTeX to forget everything that I've told it and start with a new document class?
I've modified the example environment from the lshort document:
\newwrite\examplesx#out
\newenvironment{examplesx}{%
\begingroup% Lets Keep the Changes Local
\#bsphack
\immediate\openout \examplesx#out \jobname.exa
\let\do\#makeother\dospecials\catcode`\^^M\active
\def\verbatim#processline{%
\immediate\write\examplesx#out{\the\verbatim#line}}%
\verbatim#start
}{%
\immediate\closeout\examplesx#out\#esphack\endgroup%
\noindent\makebox[\textwidth][l]{%
\begin{minipage}[c]{0.45\textwidth}%
\small\verbatiminput{\jobname.exa}
\end{minipage}%
\hspace*{0.1\textwidth}%
\framebox{%
\begin{minipage}{0.45\textwidth}%
\small\input{\jobname.exa}%
\end{minipage}
}%
}\vspace*{\parskip}%
}
and it mostly works, but I want to be able to do something like
\begin{examplesx}
\section{Section}
\end{examplesx}
and have it show up as a section in a box. I also would like it to typeset lists using the standard article style, even if I use it in beamer
I think that the easiest way of doing this is to compile some small document and then include the resultant pdf as an image into the larger document. Much simpler even if not exactly what you want. I have done this to show, in a Beamer presentation, what LaTeX articles look like.
Of course if its a REALLY simple document (e.g., a simple block of text) that you want to have inside beamer, I could recommend that you mimic the document with a TikZ "picture" that contains some text.
Maybe another approach: instead of trying to typeset things in beamer as if they would be done in article, simply typeset them with the article document class and include the result the in the beamer document.
With tcolorbox this can be done automatically:
% !TeX program = txs:///arara
% arara: pdflatex: {synctex: on, interaction: nonstopmode, shell: yes}
\documentclass{beamer}
\usepackage[most]{tcolorbox}
\begin{document}
\begin{frame}[fragile]
\begin{tcblisting}{
comment only,
pdf comment,
compilable listing,
run pdflatex,
}
\documentclass{article}
\begin{document}
\section{Section Title}
test
\end{document}
\end{tcblisting}
\end{frame}
\end{document}

Unicode characters in XeLatex

This is my LaTex script:
\documentclass[a4paper]{article}
\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{xltxtra}
\setmainfont[Mapping=tex-text]{Jenson Classico}
\begin{document}
ąęśćłó
\end{document}
I compile this using xelatex through eclipse plugin.
As Jenson Classico has no polish characters I have edited this font to add them. In Microsoft Office it works fine (I am able to use polish characters). Unfortunately in pdf generated from above tex-file it doesn't. If I use any other font (e.g. Arial) it works like a dream.
Any suggesions? I really don't have any more ideas...
Try using the polyglossia package.
\documentclass[a4paper]{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\usepackage{xunicode}
\usepackage{xltxtra}
\setdefaultlanguage{polish}
\setmainfont[Mapping=tex-text]{Jenson Classico}
\begin{document}
ąęśćłó
\end{document}
Use \char" followed by the Unicode value.
For example, ąęśćłó would be: \char"0105\char"0119\char"015B\char"0107\char"0142\char"00F3.

Resources