LyXHow to add "exam" to document class?

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
JosephPotter
Posts: 1
Joined: Mon Dec 23, 2013 10:56 pm

How to add "exam" to document class?

Post by JosephPotter »

Hello All,

I have found what I think is a new "document class" or perhaps a "module" called "exam". It can be seen here: http://ctan.org/tex-archive/macros/latex/contrib/exam/

To make that package usable has baffled me. I think this is what I am looking for to leave libre-office and use lyx for exam writing. I just want to write some simple exams for Algebra I.

I have followed several different how-to outlines but nothing is working for me.

Any help would be greatly appreciated.

-- Joe

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
tom
Posts: 73
Joined: Thu Apr 18, 2013 4:02 am

How to add "exam" to document class?

Post by tom »

Hi Joe,

You have to be a bit more specific about the problem you are facing.

Below is some example code taken from the exam documentation.

Code: Select all

\documentclass{exam}

\begin{document}

\begin{center}
  \fbox{\fbox{\parbox{5.5in}{\centering
        Answer the questions in the spaces provided on the
        question sheets.  If you run out of room for an answer,
        continue on the back of the page.}}}
\end{center}
\vspace{0.1in}
\makebox[\textwidth]{Name and section:\enspace\hrulefill}
\vspace{0.2in}
\makebox[\textwidth]{Instructor’s name:\enspace\hrulefill}

\begin{questions}
\question[10]
Why is there air?
\vspace{3in}
\question
What if there were no air?
\begin{parts}
\part[5]
Describe the effect on the balloon industry.
\vspace{2in}
\part[5]
Describe the effect on the aircraft industry.
\vspace{2in}
\end{parts}
\newpage
\end{questions}

\end{document}
StarValkyrie
Posts: 89
Joined: Fri Jan 24, 2014 12:42 am

Re: How to add "exam" to document class?

Post by StarValkyrie »

To get a new class file working with LyX, you need a .layout file for that class. Unfortunately, most classes don't have layout files written for them yet and I googled and didn't see one for exam class (or any similar exam-writing classes). But I do think an exam class would be useful to have in LyX, so I wrote a layout for this one. It's attached.

Bad News: It requires the 2.1 version of LyX which is only in beta right now (and files saved in 2.1 are not backwards compatible even to open and read without compiling).

If you use 2.1, it's pretty simple to get the exam class working with LyX. You'll need to save it to the Appdata>Roaming>Lyx>layouts folder (or the Mac or Linux equivalent) as a .layout --- open the txt file in a text editor like Notepad, Save As, then in the filename space, type exam.layout and hit save).

Bad News #2: It's a bit rough - it relies on frequent use of separators to hack together the myriad different nested environments in the class file. Also, there's one quirk I wasn't able to solve - at the beginning of each question/partno/subpart/subsubpart/bonuses you must either put an ERT with the point value in square brackets or start the line with a protected space. Failing to do one or the other will throw up errors instead of compiling.

Hope it helps.
Attachments
exam.txt
(15.43 KiB) Downloaded 1307 times
StarValkyrie
Posts: 89
Joined: Fri Jan 24, 2014 12:42 am

Re: How to add "exam" to document class?

Post by StarValkyrie »

If anyone is interested, the layout file attached here has some additional code that will prevent page breaks within a question and its multi-line multiple choice answers. (Other than that, it's the same as the basic layout file above, same instructions for how to use it).
Attachments
exam.txt
(15.7 KiB) Downloaded 1243 times
charlyms
Posts: 4
Joined: Tue Oct 07, 2014 9:37 pm

Re: How to add "exam" to document class?

Post by charlyms »

Hello,
I studied this post regarding to Lyx 2.1.
Unfortunately I got nothing concerns to lynx or Latex in my Appdata folder.
Unfortunately I don´t know Tom´s OS.
I have Windows 7 64 bit; are you sure you describe the right folder for this OS?
I get one layout folder here: C:\Program Files (x86)\LyX 2.1\Resources\layouts.
If this is is the right folder, do I have to take a cls- or a sty-file to rename?
Regards from Germany
Charlyms
StarValkyrie
Posts: 89
Joined: Fri Jan 24, 2014 12:42 am

Re: How to add "exam" to document class?

Post by StarValkyrie »

I've got Windows 7 64 bit too and its definitely Appdata/Roaming/Lyx2.1/layouts. Don't put it in the Program Files folder - that gets overwritten on upgrade. You shouldn't need to rename anything, except when you save the layout file on download and then only to change the file format to .layout - you definitely don't want to save it in place of something that's already there.
charlyms
Posts: 4
Joined: Tue Oct 07, 2014 9:37 pm

Re: How to add "exam" to document class?

Post by charlyms »

Please be so kind and show your path to your appdata-folder!
I enabled "the view to hidden folders" in the menue, but I cannot see anything.
Am I in the wrong folder.
Regards
Charlyms
StarValkyrie
Posts: 89
Joined: Fri Jan 24, 2014 12:42 am

Re: How to add "exam" to document class?

Post by StarValkyrie »

Appdata is in your User folder, so open the start menu and click on your username. That opens a window showing the contents of your user folder and Appdata should be there, slightly lighter than the others because it is a hidden folder.
QBO
Posts: 1
Joined: Fri Feb 20, 2015 8:07 am

Re: How to add "exam" to document class?

Post by QBO »

I have noticed that the errors are happening because the command which begins a question or another entity is getting concatenated to the question itself, e.g
\question
Show that ....
becomes
\questionShow ...
This could be a simple matter to fix in the layout file, but I do not know enough about layouts to be able to solve this problem. Second problem is that the class does not show itself up even after copying it to AppData\Roaming\LyX2.1. Any hints would be appreciated on this.

Best Regards
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

How to add "exam" to document class?

Post by Johannes_B »

Hi and welcome,

if a layout file seems to be faulty, i recommend to ask on the LyX users list.

Can you keep us posted about the results?
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply