2

My professor gave me a template which I compiled but it gave me lots of errors.

The code is:

\documentclass[12pt]{article}

\usepackage{rotating,graphics,psfrag,epsfig}

\usepackage{graphicx}
\usepackage{color}

\usepackage{latexsym}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage[T1]{fontenc}

\usepackage{multicol}
\usepackage[dvipdfm]{hyperref}

\usepackage{fancyhdr}
\pagestyle{fancy}

\usepackage{lastpage}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{marvosym}
\newcommand{\ff}{Marzo del 2007}

\renewcommand{\headrulewidth}{0.0pt}
\renewcommand{\footrulewidth}{0.4pt}

%\usepackage[thickspace]{SIunits}

\usepackage[a]{esvect}
\usepackage{shortlst}

\usepackage{marvosym}
\usepackage[version=3]{mhchem}

\newcommand{\solucion}{\noindent\textbf{Soluci\'on}}
\newcommand{\comentario}{\noindent\textbf{Comentario}}
\newcommand{\nota}{\noindent\textbf{Nota}:}
\newcommand{\suge}{\noindent\textbf{Sugerencia}:}
\newcommand{\analisis}{\noindent\textbf{An\'alisis}}
\newcommand{\modelo}{\noindent\textbf{Modelo}}


\fancyhead[L]{} 
\fancyhead[C]{}
\fancyhead[R]{} 
%
\fancyfoot[L]{http://fisica.usach.cl/$\sim$cesparza/}
%\fancyfoot[C]{\ff} 
\fancyfoot[C]{} 
\fancyfoot[R]{TeoIngMat-EXA1s11.pdf -- 15 noviembre 2011}

\headwidth 18.0cm
\textwidth 18.0cm %18.0cm
\textheight 25.00cm % era25
\oddsidemargin -0.8cm
\evensidemargin -0.8cm
\topmargin -3.5000cm %era  -2.0cm
\columnsep 0.3cm
\parindent 0pt

\newcommand{\ia}{\'{\i}}
\newcommand{\xu}{\rm {\widehat{\bf{x}}}}
\newcommand{\yu}{\rm {\widehat{\bf{y}}}}
\newcommand{\zu}{\rm {\widehat{\bf{z}}}}

\newcommand{\iu}{\mathbf{\hat{\imath}}}
\newcommand{\ju}{\mathbf{\hat{\jmath}}}
\newcommand{\ku}{\mathbf{\hat{\kappa}}}
\newcommand{\kuw}{\mathbf{\widehat{\kappa}}}



\usepackage[dvipdfm]{hyperref}
\hypersetup{ 
pdfauthor = Carlos Esparza Barrera, 
pdftitle = TeoF1-IngMat-EXA1s11.pdf, 
pdfsubject = 2red, 
pdfkeywords =carlos.esparza@usach.cl, 
pdfcreator = {LaTeX con la paqueteria hyperref }, 
pdfproducer = {dvpdfm} 
}



\usepackage{type1cm} 
\usepackage{eso-pic}
\usepackage{color} 

\begin{document}

 \psfrag{xu}{$\widehat{\bf{x}}$}
 \psfrag{yu}{$\widehat{\bf{y}}$}
\psfrag{iu}{$\mathbf{\hat \imath}$}
 \psfrag{ju}{$\mathbf{\hat \jmath}$} 
 \psfrag{i}{$\hat \imath$}
 \psfrag{j}{$\hat \jmath$}

\textbf{Departamento de Fisica \hfill Universidad de Santiago de Chile} 

Teoria a Física I (22104)\hfill \textbf{EXAMEN} \hfill Ingeniería Matemática  \vspace{0.1cm}

\hline \hline \vspace{0.2cm}

Prof. Carlos H. Esparza-Barrera \hfill \begin{LARGE} \raisebox{-0.5ex}{\Email}                               
           \end{LARGE}  ~carlos.esparza@usach.cl \hfill \begin{LARGE}\Telefon \end{LARGE} ~(56-2-)7181239
\hfill Oficina 27 \\[0.1cm] 

\hline
\begin{itemize}

\item  \begin{large} \textbf{Esta prueba
consta de cuatro problemas, usted debe responder tres de ellos. La
elección es suya y debe indicarla en la hoja. Si responde los cuatro, se considerarán los tres
peor evaluados}\end{large}.  \hfill  Cada problema vale $2,0$ puntos. 

\item Fundamente su razonamiento; haga esquemas explicatorios. Use
l\'apiz  indeleble; en caso contrario, no puede pretender una segunda revisi\'on de su trabajo. Exprese sus
repuestas numéricas con 3 CS.


\item Las situaciones y los valores num\'ericos de los datos suministrados no necesariamente corresponden a
los de un experimento o situaci\'on pr\'actica real.  Se pretende que usted  trabaje cada problema  con
el modelo adecuado en el marco de la  teor\'ia  pertinente y obtenga las predicciones correspondientes. 

\end{itemize}
\hline

\begin{multicols}{2}
\begin{enumerate}


\item problema 1

\item ...

\item ...


\item ...


\item ...


\item ...
\end{enumerate}

Compiling in Latex=>PS=>PDF, I have the following errors:

Misplaced \noalign x4 and Emergency stop.

I don't know how to fix this.

The result should be the following:

enter image description here

After the last horizontal line, I edited the problems so there's no text in there as you can see in the code.

I had to repost this because I messed up in the other thread. I appreciate the help and thanks in advance.

  • 2
    Please don't post duplicate questions. You can simply edit your original posting. – Paul Gessler Apr 30 '15 at 17:47
  • Sorry, I'm new in these forums. Thanks for the advice. – Alejandro Apr 30 '15 at 17:49
  • 1
    The template uses dvpdfm option on several packages so it is not for latex-ps-pdf or for pdflatex but for latex-dvi-pdf via dvipdfm, as such psfrag package shouldn't be loaded. epsfig package should never be loaded, you load marvosym twice, you shouldn't use \bf or \rm, especially in math mode... – David Carlisle Apr 30 '15 at 18:49
  • You mean I can't compile in LaTeX=>PS=>PDF? How can I do it to compile with that profile? – Alejandro Apr 30 '15 at 18:53
  • 3
    This seems to be the code that initiated writing l2tabu. Most of the code is obsolete by now, starting from scratch would be much faster than starting to fix and hack. – Johannes_B Apr 30 '15 at 19:49
2

Here is an example more in the spirit of LaTeX, as I see it. (Not to compete with the other answers but to demonstrate the benefits of the LateX approach, for those who see it as beneficial).

If you needed to produce many such documents, you could design a custom preamble (or package) along these lines. This completely separates presentation from style, so that the markup inside the document environment is completely semantic. And I think it also uses fairly simple solutions to achieve the desired layout style.

\documentclass{article}

\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage[margin=1.5in]{geometry}
\usepackage{multicol}

\usepackage{marvosym} % for icons
\usepackage{url} % for e-mail address
\usepackage{sectsty}  % for customizing section font

\sectionfont{\normalsize\bfseries}

% Horizontal rule
\newlength{\normalrulethickness}
\setlength{\normalrulethickness}{0.4pt}
\newcommand{\thinrule}{\noindent\rule{\linewidth}{\normalrulethickness}}
\newcommand{\thickrule}{\noindent\rule{\linewidth}{2\normalrulethickness}}
\newcommand{\doublerule}{%
    \thickrule%
    \llap{\rule[2pt]{\linewidth}{\normalrulethickness}}%
}
% Letterhead at top of page
\newcommand{\letterhead}{%
    \noindent%
    \textbf{\department}\hfill \textbf{\university}\newline
    \course\hfill \documentname\hfill \subject\newline
    \doublerule\par\smallskip
    {\small\noindent%
    \professor\hfill \emailicon\ \email\hfill \phoneicon\ \phone\hfill \office%
    }\par\bigskip%
}

% Commands to set the values in the \letterhead
\newcommand{\setdepartment}[1]{\gdef\department{#1}}
\newcommand{\setuniversity}[1]{\gdef\university{#1}}
\newcommand{\setcourse}[1]{\gdef\course{#1}}
\newcommand{\setsubject}[1]{\gdef\subject{#1}}
\newcommand{\setdocumentname}[1]{\gdef\documentname{#1}}
\newcommand{\setprofessor}[1]{\gdef\professor{#1}}
\newcommand{\setemail}[1]{\gdef\email{\url{#1}}}
\newcommand{\setphone}[1]{\gdef\phone{#1}}
\newcommand{\setoffice}[1]{\gdef\office{#1}}

% Icons in letterhead
\newcommand{\emailicon}{\Email} % from marvosym
\newcommand{\phoneicon}{\Telefon}


% Block of instructions with rule before and after
\newenvironment{instructions}{\thickrule}{\thickrule}

% 2-column exam questions
\newenvironment{examquestions}
    {\begin{multicols}{2}}
    {\end{multicols}}

\newcommand{\pointvalue}[1]{\hfill\mbox{#1}}
\newcommand{\strong}[1]{\textbf{#1}}

\begin{document}
\setdepartment{Departamento de Física}
\setuniversity{Universidad de Santiago de Chile}
\setcourse{Teoría Física (22104)}
\setsubject{Ingeniería Matemática}
\setdocumentname{EXAMEN}
\setprofessor{Prof.~Carlos H.~Esparza-Barrera}
\setemail{carlos.esparza@usach.cl}
\setphone{(56-2-)7181239}
\setoffice{Oficina 27}

\letterhead

\begin{instructions}
\begin{itemize}
\item \strong{%
Esta prueba consta de cuatro problemas, usted debe responder tres de ellos.
La elección es suya y debe indicarla en la hoja. 
Si responde los cuatro, se considerarán los tres peor evaluados.
}\pointvalue{Cada problema vale $2,0$ puntos.}
\item Fundamente su razonamiento; haga esquemas explicatorios. [\dots]
\item Las situaciones y los valores numéricos de los datos suministrados [\dots]
\end{itemize}
\end{instructions}

\begin{examquestions}

\section{Insectos}
Algunos coleópteros pueden proyectarse verticalmente [\dots]

\section{Esferas de aluminio y fierro}
La masa de un metro cúbio de Al es $2,70 \times 10^3$~kg [\dots] %better to use siunitx 

\end{examquestions}


\end{document}

enter image description here

  • 1
    You should add, that reusing this stuff would mean hiding most of the definitions in a wrapper class/package. Since this is a physics topic, maybe package siunitx comes in handy. There might be a lot more units in the text we don't see. :-) – Johannes_B May 1 '15 at 20:20
  • I decided to remove the \section stuff and adding the enumerate environment. The problem is that when writing in first item, the columns try to balance each other. How can I make when using \newpage it jumps to write in second column? – Alejandro May 5 '15 at 2:36
  • @Oshnaj This would be a good separate question, if you can make a simple example document. But first look at the questions on this site about the various multicolumn packages. – musarithmia May 5 '15 at 2:52
7

I left numerous comments in the code below highlighting bad code, however this version runs without error in latex and pdflatex

\documentclass[12pt]{article}

% never load epsfig it is just for emulating latex2.09 documents from 1980's
% rotating might be needed for sideways table, otherwise not
% psfrag doesn't work as is with pdflatex or dvipdfm
% graphics is loaded later
%\usepackage{rotating,graphics,psfrag,epsfig}


\usepackage{graphicx}

% color loaded later
%\usepackage{color}

\usepackage{latexsym}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}


%\usepackage[T1]{fontenc}

\usepackage{multicol}

%%% this is loaded later with different options
%\usepackage[dvipdfm]{hyperref}

\usepackage{fancyhdr}
\pagestyle{fancy}

\usepackage{lastpage}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{marvosym}
\newcommand{\ff}{Marzo del 2007}

\renewcommand{\headrulewidth}{0.0pt}
\renewcommand{\footrulewidth}{0.4pt}

%\usepackage[thickspace]{SIunits}

\usepackage[a]{esvect}

% no idea what this is, not in texlive
%\usepackage{shortlst}

\usepackage{marvosym}
\usepackage[version=3]{mhchem}

\newcommand{\solucion}{\noindent\textbf{Soluci\'on}}
\newcommand{\comentario}{\noindent\textbf{Comentario}}
\newcommand{\nota}{\noindent\textbf{Nota}:}
\newcommand{\suge}{\noindent\textbf{Sugerencia}:}
\newcommand{\analisis}{\noindent\textbf{An\'alisis}}
\newcommand{\modelo}{\noindent\textbf{Modelo}}


\fancyhead[L]{} 
\fancyhead[C]{}
\fancyhead[R]{} 
%
% don't use math \sim
\fancyfoot[L]{\url{http://fisica.usach.cl/~cesparza/}}
%\fancyfoot[C]{\ff} 
\fancyfoot[C]{} 
\fancyfoot[R]{TeoIngMat-EXA1s11.pdf -- 15 noviembre 2011}

\headwidth 18.0cm
\textwidth 18.0cm %18.0cm
\textheight 25.00cm % era25
\oddsidemargin -0.8cm
\evensidemargin -0.8cm
\topmargin -3.5000cm %era  -2.0cm
\columnsep 0.3cm

% I left this but having \parindent and \parskip both 0pt
% means that paragraph breaks  are not really visible
\parindent 0pt

\newcommand{\ia}{\'{\i}}

% The  \rm never did anything here and both
% \rm and \bf have been deprecated since 1994
%\newcommand{\xu}{\rm {\widehat{\bf{x}}}}
%\newcommand{\yu}{\rm {\widehat{\bf{y}}}}
%\newcommand{\zu}{\rm {\widehat{\bf{z}}}}
\newcommand{\xu}{\widehat{\mathbf{x}}}
\newcommand{\yu}{\widehat{\mathbf{y}}}
\newcommand{\zu}{\widehat{\mathbf{z}}}

\newcommand{\iu}{\mathbf{\hat{\imath}}}
\newcommand{\ju}{\mathbf{\hat{\jmath}}}
\newcommand{\ku}{\mathbf{\hat{\kappa}}}
\newcommand{\kuw}{\mathbf{\widehat{\kappa}}}



%\usepackage[dvipdfm]{hyperref}
\usepackage{hyperref}
\hypersetup{ 
pdfauthor = Carlos Esparza Barrera, 
pdftitle = TeoF1-IngMat-EXA1s11.pdf, 
pdfsubject = 2red, 
pdfkeywords =carlos.esparza@usach.cl, 
pdfcreator = {LaTeX con la paqueteria hyperref }, 
pdfproducer = {dvpdfm} 
}



\usepackage{type1cm} 
\usepackage{eso-pic}
\usepackage{color} 


\DeclareUnicodeCharacter{00ED}{\'{\i}}
\DeclareUnicodeCharacter{00F3}{\'{o}}
\DeclareUnicodeCharacter{00E1}{\'{a}}

\begin{document}



% psfrag doesn't work with pdf backends
% \psfrag{xu}{$\widehat{\bf{x}}$}
% \psfrag{yu}{$\widehat{\bf{y}}$}
%\psfrag{iu}{$\mathbf{\hat \imath}$}
% \psfrag{ju}{$\mathbf{\hat \jmath}$} 
% \psfrag{i}{$\hat \imath$}
% \psfrag{j}{$\hat \jmath$}

\textbf{Departamento de Fisica \hfill Universidad de Santiago de Chile} 

Teoria a Física I (22104)\hfill \textbf{EXAMEN} \hfill Ingeniería Matemática \vspace{0.1cm}

%\hline is only used in tables
%\hline \hline 
\vspace{0.2cm}

Prof. Carlos H. Esparza-Barrera \hfill \begin{LARGE} \raisebox{-0.5ex}{\Email}                               
           \end{LARGE}  ~carlos.esparza@usach.cl \hfill \begin{LARGE}\Telefon \end{LARGE} ~(56-2-)7181239
\hfill Oficina 27 

% never end a paragraph with \\
%\\[0.1cm] 

%\hline
\begin{itemize}

\item  \begin{large} \textbf{Esta prueba
consta de cuatro problemas, usted debe responder tres de ellos. La
elección es suya y debe indicarla en la hoja. Si responde los cuatro, se considerarán los tres
peor evaluados}
%Always include a paragraph end _within_ a size change this blank line is needed

\end{large}.  \hfill  Cada problema vale $2,0$ puntos. 

\item Fundamente su razonamiento; haga esquemas explicatorios. Use
l\'apiz  indeleble; en caso contrario, no puede pretender una segunda revisi\'on de su trabajo. Exprese sus
repuestas numéricas con 3 CS.


\item Las situaciones y los valores num\'ericos de los datos suministrados no necesariamente corresponden a
los de un experimento o situaci\'on pr\'actica real.  Se pretende que usted  trabaje cada problema  con
el modelo adecuado en el marco de la  teor\'ia  pertinente y obtenga las predicciones correspondientes. 

\end{itemize}
%\hline

\begin{multicols}{2}
\begin{enumerate}


\item problema 1

\item ...

\item ...


\item ...


\item ...


\item ...
\end{enumerate}

\end{multicols}
\end{document}
  • Could you say why fontenc before inputenc? – cfr May 1 '15 at 0:02
  • 1
    If you do it the wrong way around, 90% of the 't's don't get deleted when you print, do they? – cfr May 1 '15 at 0:16
  • In answer, Ulrike Fischer says that the order does not matter. But that answer is from 2 years ago, so maybe inputenc no longer contains the special protections he mentions there? – cfr May 1 '15 at 0:22
  • 1
    @cfr actually it doesn't make any difference as inputenc delays checks to begin document. But for utf8 (unlike other input encodings) it bases the characters it defines on the known font encodings (from fontenc) to avoid defining the whole of unicode. – David Carlisle May 1 '15 at 8:50
  • OK. Good. Thanks. It would be inconvenient to have to change the order, so I'm glad there is no reason to. – cfr May 1 '15 at 11:37
1

I show that plain TeX code is more straightforward than LaTeX. To create your exam document we can do the following:

\input opmac

{\mubytein=0 
 \mubyte\revquestion ¿\endmubyte \gdef\revquestion{?`}
}
\let\secfont=\seccfont  
\font\mvfont=umvs at12pt 
\def\mvchr#1{{\mvfont\char#1}}
\def\Email{\mvchr{107}}  \def\Telefon{\mvchr{84}}
\def\u{\,\rm}

\line{\bf Departamento de Fisica \hfil Universidad de Santiago de Chile}
\line{Teoría a Física I (22104)\hfil {\bf EXAMEN}\hfil 
      Ingeniería Matemática\strut}
\hrule \kern1.5pt \hrule \medskip
\line{Prof. Carlos H. Esparza-Barrera\hfil 
      \lower.5ex\hbox{\Email} carlos.esparza@usach.cl\hfil
      {\Telefon} (56-2-)7181239\hfil Oficina 27\strut}
\medskip \hrule
\bigskip

\begitems \style x \parskip=\medskipamount
* {\typosize[12/14]\bf Esta prueba consta de cuatro problemas, 
  usted debe responder tres de ellos. La elección es suya y debe
  indicarla en la hoja. Si responde los cuatro, se considerarán 
  los tres peor evaluados.\par}
* Fundamente su razonamiento; haga esquemas explicatorios. Use
  lápiz  indeleble; en caso contrario, no puede pretender una segunda
  revisión de su trabajo. Exprese sus
  repuestas numéricas con 3 CS.
* Las situaciones y los valores numéricos de los datos suministrados no   
  necesariamente corresponden a los de un experimento o situación práctica   
  real. Se pretende que usted trabaje cada problema con el modelo 
  adecuado en el marco de la teoría pertinente y obtenga las predicciones
  correspondientes.
\enditems

\hrule\bigskip

\begmulti 2

\sec Insectos


Algunos coleópteros pueden proyectarse verticalmente por sí mismos con una
aceleración de unos $400{\u g}$ (ésto es, un orden de magnitud superior de
lo que un ser humano con entrenamiento puede resistir). El impulso proviene 
en algunos casos de desdoblar sus patas y en otros de curvar violentamente 
el abdomen, hecho que origina un recorrido vertical durante la aceleración 
de unos 0,5{\u cm}. Bajo las anteriores consideraciones:

\begitems \style n
* ¿A qué altura pueden saltar?
* ¿Cuánto tiempo permanecen en el aire?
\enditems

\sec Dos bloques

Un bloque de masa $m= 30{\u kg}$ desliza con aceleración horizontal
$a_{\u m}= 3{\u m/s^2}$ por la parte superior de otro bloque de masa
$M= 30{\u kg}$ por la acción de una fuerza horizontal de magnitud   
$F= 160{\u N}$, como se indica en la Figura.

El bloque de masa $M$ está sobre una superficie horizontal sin roce. Entre
los bloques
$m$ y $M$ hay roce.
\begitems \style n 
* Determine el coeficiente de roce cinético entre los bloques.
* Determine la aceleración del bloque $M$ durante el tiempo que $m$ está
  completamente en contacto con $M$.
\enditems

\endmulti
\bye

The result is:

examen

You can try to preocess this by pdfcsplain document. The pdfcsplain format is recommended here in order to right interpretation of UTF-8 codes such as ó, í, á. The reversed question mark can be declared in csplain by \mubyte primitive (see the third line in the code).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.