## Paul E. Johnson <pauljohn at ku.edu>
## 2013-02-09
## Step by step LyX install Notes
## Test operating system is Windows-7 32 bit virtual machine.
## User making install is NOT a "limited" account. (Recall that
## the limited account is not the default account type, but it is the
## type that all Windows
## users should use as their primary day-to-day login).
## I expect this install would fail if run by a limited user.
## I'm writing down every step.
## Go to http://www.lyx.org
Download
LyX-2.0.5.1-Bundle-4.exe
Right click, run as administrator.
Say yes to proceed
License prompt: agree
Install for anyone using this computer
Destination Folder. I get rid of all spaces where possible
C:\Program Files\LyX-2.0
Select Components.
Leave LyX, File associations, Desktop icon
Check JabRef
I left dictionaries.
Thesaurus is new feature to me, never tried before, will try now.
--Check Thesaurus, click the + and UNCHECK lots of languages.
Name Start Menu Folder whatever you like (I left default)
Now you see the benefit of the "Bundle" install. The download included
basic-miktex, jabref (bibtex editor). Almost immediately, menu says:
LyX Setup:
Now the installer of the LaTeX-distribution "MikTeX" will be launched.
To install the program, press the "Next" button in the installer windows
until the installation begins.
!!!Please use all default optinos of the MikTeX installer!!!
That emphatic statement there (I'm almost sure) relates to the problem
that the MikTeX distribution will need many addon packages and there
has been trouble with the packages that download "on the fly" or without
user permission. So I'm following their guide to see if their way works.
In the past, there was trouble.
I accepted the MikTeX conditions, it asks where to Install MikTeX.
I'm going to get rid of the space:
C:\Program Files\MiKTeX
Now the problem. LyX instructions said leave defaults, but I cannot
believe that means I have to accept A4 paper. So I refuse.
But the option "Install missing packages on the fly" is marked "Ask me first"
and that's default, but it has been a big big trouble for me in the past.
The problem was that a flaw in Windows or MikTeX or LyX caused the popup
permission window to fail, and so LyX would hang. I'll accept the
default now, and then see what happens.
Now the MiKTeX install window appears and it is doing a lot of work.
This part takes at least 10 minutes. At several points, I thought it was
hung. I'm doing this in a place where the firewall allows http traffic,
but it might block other download types that the system tries. We will
see.
While I wait, I'd mention that I've wrestled with the LyX install in
Windows many times and on our remote desktop servers, we experienced
the same problem. Every time a new user tries to use LyX for the first time, there
is a super long delay, as long as 40 minutes, before LyX works.
Sometimes it turns out that some prompt window has failed to open.
Sometimes, we find that the LaTeX distribution is trying to download more packages.
Eventually it does work, but most of us give up, concluding LyX does
not work. The system administrators found a work around, I posted it
in the Lyx-devel email list.
I am pretty sure the hold up is just Windows and MiKTeX not working
correctly together for users who are not administrators. To work with
the MiKTeX stuff, one really needs admin power--since it is changing
stuff in C:\Program Files\MiKTeX. But the LyX users are not administrators,
so when LyX needs a package, it can't get it.
One solution would be to install all MiKTeX packages with the MiKTeX
installer.
Anyway, this is a long standing problem which can be solved with patience.
On a user's laptop, where there is only one user to worry about, we have
always found a way to get it going.
Usually, after the initial 30 minute wait to view the very first
document, then LyX will be fine.
As the MiXTeX install is proceeding, I notice again this weird/frustrating
thing that Windows does. It pops up windows below other windows.
I thought the install was working, but actually it was waiting for me to
say "NEXT" in a menu that had popped up BELOW the Setup popup window.
I realize there are actually two windows on screen, one on top of the other.
1. LyX 2.0.5.1 Setup (seems to indicate it is working)
2. Basic MiKTeX 2.9.4757 Installer (32-bit)
The Basic MikTex was underneath the other, waiting for me to say next.
So, when you think the install is dead, move the windows around and hunt for pop up windows.
After I hit "next", then the install proceeds.
A new popup appears:
LyX 2.0.5.1 Setup
The LaTex distribution "MikTeX" will be used together with LyX. It is recommended to
install available MiKTeX updates using the program "MikTeX Update Wizard" before you
use LyX for the first time. Would you now check for MiKTeX Updates?
I said yes.
A window pops up asking where to check for updates. I Said find the nearest repository,
and there was a long delay while "Searchin..."
And then The MikTeX install CRASHED.
Popup window says:
MiKTeX Update Wizard has stopped working.
The Details indicate:
Problem Signature
Problem Event name APPCRASH
Application Name    miktex-update_admin.exe
Application Version:Â Â Â Â 2.9.4745.0
Application Timestamp:Â 50dd63c1
OS Version  6.1.7600.2.0.0.256.48
I've seen APPCRASH from LyX before, it is one of the Windows problems. I've
never gotten a clear explanation, nobody I know who uses Windows cares enough
to learn what's wrong with it or why that happens. Hopefully, some Windows
user reads this and tells me what is wrong with it. Over the years, I've
come to conclude APPCRASH is just another symptom of the Windows OS problem.
The OS if flaky enough so that only the Microsoft company can write good software
for it, and the Microsoft company is not interested in fixing that because it
perpetuates their monopoly on Office software. Recall, MS did loose the
Netscape & Word Perfect lawsuits, only to be excused by the US Government.
Now the LyX 2.0.5.1 Setup window is back on top. It says:
Configuring LyX (MiKTeX may download missing packages, this can take some time)...
I don't know if the APPCRASH will frustrate this. I'm waiting. The encouraging
thing is that the green progress bar in the panel is almost all the way across.
I'll click the "Show details" button to try to tell if it is actually going anything.
Good, it shows lots of downloads going on.
downloading from http://ftp.fernuni-hagen.de/ftp-dir/pub/mirrors/www.ctan.org/systems...
extracting files from ttk.tar.lzma ...
As long as that's doing something, we are OK
Wow, this is slow. It's been 15 minutes.
And, as I watch the downloads, I'm remembering the problem that will come up in the future when more packages are needed.
If I run LyX as a non-administrator, will the packages be installed? Will LyX be able to trigger MikTeX to ask me for permission and a password? In 2011, the answer was NO, but I always have hope. But the APPCRASH in the MikTeX updater makes me doubtful.
Hooray. It finished.
The final panel asked me if I want to start LyX.
Nothing appears to happen.
Did LyX die? Is it doing that super-slow-startup problem I've seen before?
I'll try Alt-Ctrl-Delete to get task manager open. If LyX is running, it should show.
I see nothing, so I'll try a double-click on the LyX icon
I see the little circle for 20 seconds, then LyX opened with a welcome window.
And a nice introduction to LyX it is.
I will try the View/PDF pull down to see what happens.
GREAT. Right away, the PDF opens on the screen. It is using the PDF viewer from the
TeXWorks project, which is part of MiKTeX. In the old days, it used to use a
program called Yapp. I don't mind.
If you try the same exercise, you will note the fonts in that "splash.lyx" document
LOOK HORRIBLE. They are all fuzzy. The default fonts are for postscript, not
PDF. This is one of the historical frustrations with LaTeX in general and LyX in
particular. Every single new user who comes along says "my PDF output looks
terrible" and the experts respond, "Oh, did you want good looking output? Go
read a 92 page manual about postscript, Type I, Type II, True Type, and some
other font crap and check back later." It drives me crazy.
Here's the instant fix. In the LyX document, open Document -> Settings -> Fonts
and change the font type to "Latin Modern". You have to do this for
Serif
Non-Serif
Typewriter
separately. If you don't like LatinModern, Palatino works well too. And, in fact,
the True Type fonts are usually workable too.
The multiplicity of font formats, their non-interchangeability is a long standing
problem that people smarter than we are are fixing as we speak.
I'm wondering if the TeXWorks PDF viewer is not so great. I'm going to open LyX
Tools -> Preferences to select a viewer, either Adobe Acroread or one of the GTK
viewers (Okular, etc).
That's the end of session 1, more will follow
##### Session 2
One goal is to make LyX work with R and Sweave.
The LyX team has worked on this, now LyX has an Sweave
module that may make this easier for beginners. I will
try this out "barefoot," as if I did not plan to make a lot
of customizations.
I open LyX, and then Document -> Settings -> Modules
and choose Sweave.
Note in the small pnanel it says it requires sweave, fancyvrb.
The Sweave.sty file is distributed along with R.
I went into the MiXTeX install, to this spot:
C:\Program Files\MikTeX\tex\latex
and In there I created a folder "R".
Then I copy the Sweave.sty file from the R distribution into
that folder. The Sweave.sty file for R file is under
C:\Program Files\R\share\texmf\tex\latex
Copy that into the MikTeX location.
BUT WAIT! Its not ready yet.
Even if that were the only file that needed insertion, we still
neeed to make MikTeX aware of it. (On unix/linux, we'd run 'texhash'
in a terminal to force a re-scan.
In Windows, Click the Start Menu -> MixTeX -> Admin -> Package Manger.
Recall the LyX panel warned it needed Sweave and also fancyvrb.
My MiKTeX seems to say that fancyvrb is already installed. So all
I need to do is force a re-scan of the style directories. How to
do that in Windows?
In MikTeX Package manager, click "Repository" -> "Synchronize".
While you are in there, you can install any other latex packages
you might need.
You could also do "Task" -> "Update Wizard". For me that dies, says
"The update wizard could not be found". Possibly related to the
APPCRASH i had before.
Now, lets see if this will work in LyX. Want to try it out?
STOP. You have to let LyX notice the MikTeX changes.
In Lyx, Click "Tools" -> "Reconfigure"
Then close LyX.
Restart LyX. Start a new document. Don't worry about details
in Document -> Settings yet, we just need to go step by step.
Type something, try to compile it (View -> PDF).
All good? Now go into Document -> Settings -> Modules and
activate the Sweave module.
Hm. Drag. Activation still fails, saying
The module sweave requires a package that is not available
in your LaTeX installation, or a converter that you have
not installed. LaTeX output may not be possible. Missing
prerequisites:Â Â sweave->latex. See section 3.1.2.3
of the User's Guide for more information.
I've been here before. We need to figure how LyX is supposed to call R.
About 10 years ago, I started the documentation for this in the
LyX website, I notice people have been updating. Yeah. Go see:
http://wiki.lyx.org/LyX/LyxWithRThroughSweave
In the PATH prefix bar, add semicolon and
C:\Program Files\R\bin
(that's where my R is)
Now make LyX rescan by Tools -> Reconfigure, then close LyX
Restart LyX, File -> New, then Document -> Settings -> Module
choose Sweave, add, and there are no more errors.
Now go back to the document and type anything and make sure it compiles.
Don't try any Sweave stuff yet, just type text or such.
Now we test out Sweave MY WAY. I've been doing this a long time, and I DO NOT like the effort to make the R code blend "seamlessly" into the on screen document. I want the R code to be AS VISUALLY distinct as possible. So I put my R chunks in TeX boxes.
Hit the TeX button and a red box appears, and type this
<<>>= x <- rnorm(5) mean(x) var(x) @
(Correction 2015-10-13: don't forget these begin with <<>>= and end with @. Arguments like the chunk name, figure parameters, etc can be inside the <<>>.
View -> PDF, and for me, it worked?
If it did not work for you, then review the steps and find out why.
If it did work, then your next step is to learn some of the
arguments that you can put between the <<>>= in the R chunk.
The whole Sweave idea was created by Friedrich Leisch and he has
some good documents about it.
I've started a web page about latex and sweave tips here:
https://pj.freefaculty.org/latex
That page points at to some Sweave starter documents.
Over the long run, I think this is where you want to be.
1. Don't use the default Sweave style. It is based on the
LaTeX Verbatim class, which is bad in many ways. Instead, switch
to use Frank Harrell's Sweavel.sty class, which uses LaTeX
listings instead of Verbatim to render the R code and output.
It is much more versatile and beautiful. So you need to copy
the Sweavel.sty file from his website, put it in the same
place where you put the R Sweave.sty file, make MikTeX reconfigure.
Then you put some magic in the LyX document preamble (Document->
Settings -> Preamble) and make a few boiler plate changes in the
document. I've used this in at least 50 documents in the last
5 years and it can be made to work out. Just about everything
under
https://pj.freefaculty.org/guides
uses that.
2. Set the various R options to put the R output into a
separate folder, and also to BREAK UP the LaTeX output from
Sweaving into separate files. In all my chunks after that,
I start like so
<<chunk10, ..other-options-you-use, include=F>>=
R code here
@
That causes the R output to be named "prefix-chunk10" in the
R output folder. If the code makes a figure, it has a figure
"prefix-chunk10.pdf". So in LyX document, I insert that
tex output and the figure exactly where I want. In other workds,
I no longer let Sweave decide where to put the output. I put
it in myself
\input{file-name-here}
\includegraphics[]{file-name-here}
The advantage of this setup is that we can "TURN OFF" the Sweave module, and the document can still be compiled because the output from the previous Sweave is saved in a folder.
I don't want to write out all the details here, I only mention
it because, if you go looking into my guides folder, you see
I almost always have a sub-folder "plots" and that is the place
where I have R dump the figures and the input and output code.
That stuff is there, waiting to be inserted into the document however
I like.
3. To make a Beamer presentation using Sweave, a whole horrible
layer of awfulness comes into play. Both the Sweave approaches,
either the default Sweave.sty (which uses LaTeX Verbatim) and
Sweavel.sty (which uses Latex listings) will not cooperate with
the default Beamer slide. It is necessary to start a slide in
TeX code like so
\begin{frame}[containsverbatim]
\frametitle{your title here}
type the slide in here
\end{frame}
It has been a long standing wish for LyX to more gracefully
interact with customized frames. But until it is completely
solved, I'm typing all the frames in TeX boxes. There is
talk in the lyx-devel list about making frames that allow a
[fragile] marker to achieve same purpose, but that doesn't really
get the job done because it isn't exactly the same as
[containsverbatim] and it also does not allow the other
frame option that I often use. That is [allowframebreaks].
By far the most horrible hassle in writing slides is making
sure that the content fits on a single screen. There's no
way to tell if it fits without compiling it. And while you
are in the creative mood, you don't want to stop writing
to re-arrange content so it fits on a screen. In that case,
the easiest thing to do is to open a multi-screen frame like
so
\begin{frame}[containsverbatim, allowframebreaks]
\frametitle{My Frame is }
write whetever you want here.
\end{frame}
The default output is a little ugly, it uses some roman numerals in the frame names in the output. But that is easily fixed by a customization of the document prefix. Most of my stuff in the guides folder incorporates that.