LyXclassicthesis | LyX vs. LaTeX Search Path

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
sheepd
Posts: 4
Joined: Thu Jul 07, 2011 4:32 pm

classicthesis | LyX vs. LaTeX Search Path

Post by sheepd »

Hello,
I have been looking for an option to add the folder where the currently active file resides to the LaTeX search path in LyX.
I searched the fora thoroughly, and found this post: http://www.latex-community.org/forum/vi ... 19&t=13381, where somebody's problem arises from similar circumstances (just the 1st post).
OS is Windows 7, using MikTex 2.9.
Unfortunately, the solution then goes into a direction which does not work for me.
I am using the classicthesis package (current version) with the *.layout file placed at %APDDATA%\LyX2.0\layouts.
The package mainly consists of the two files classicthesis.sty and classicthesis-preamble.sty, where the latter is loaded by the LyX setting and in turn loads the main file classicthesis.sty.
I have modified the file classicthesis-preamble.sty as told by the documentation, which defines a few commands such as \myName, \myDepartment etc., to use my personal information.
Both *.sty files are placed in the same directory (call it $folder) as my *.lyx file.

The following steps then reproduce the error:
I created a new LyX-document doc.lyx and put the LaTeX-Code "\myName" inside. Set the document class in the Document Settings dialog to "classicthesis".
When I create a *.pdf file via pdflatex in LyX, all I get to see is the standard value (name of the package author), as if I hadn't modified anything.
On the other hand, if I export the document to "Latex (pdflatex)" and compile it manually via "pdflatex doc.tex", everything works as intended.

I was able to isolate the problem: Apparently, LyX uses a different package search path. Running "kpsewhich classicthesis-preamble.sty" inside $folder gives the intended output $folder/classicthesis-preamble.sty.
But LyX does not seem to look there and asks MikTex to install the missing package. If I then modify the file %appdata%\MiKTeX\2.9\tex\latex\classicthesis\classicthesis-preamble.sty, it correctly shows up.

This is kind of a kludge, because the file also contains variables which are specific to the current document and thusly better changed in the local version inside $folder. I am posting this in detail so anybody who might encounter a similar problem can find this.
So, in the end, the question remains: How do I coax LyX to load any package from the current folder first before trying the repository?

Stuff I tried:
*Renaming classicthesis-preamble.sty and including the renamed file. Gives the problem that all those commands are already defined inside the MikTex-version which is included by LyX at an earlier point and therefore my newer definitions are discarded. Also, seems kludgy.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

sheepd
Posts: 4
Joined: Thu Jul 07, 2011 4:32 pm

Re: classicthesis | LyX vs. LaTeX Search Path

Post by sheepd »

Sorry for double-posting, but since no one answered I guess I must've overcomplicated the whole thing or misposed my question.
So, let me rephrase and boil it down:
How does LyX locate LaTeX *.sty files in general, and especially ones which might be included through a *.layout file?
Is there any way to tune the mechanism involved in resolving \usepackage{} directives in LyX?

Thanks!
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

classicthesis | LyX vs. LaTeX Search Path

Post by meho_r »

Here's what I did and it worked:

1. Downloaded ClassicThesis package for LyX.
2. Created a new directory, let's call it Test and placed both .sty files, together with .layout file into it. Also, I saved my .lyx file into this directory.
3. In LyX: Document > Settings > Document Class > Local Layout, and then set "classicthesis.layout" from Test dir as my document class.

AFAIK, LyX respects LaTeX path, so I'm not sure what went wrong in your case. All I can say is to try reconfiguring LyX (Tools > Reconfigure), then restart it and try compiling your document again.

Also, .sty files in working directory should take precedence over those installed in system dirs.
sheepd
Posts: 4
Joined: Thu Jul 07, 2011 4:32 pm

classicthesis | LyX vs. LaTeX Search Path

Post by sheepd »

meho_r wrote:Here's what I did and it worked:

1. Downloaded ClassicThesis package for LyX.
2. Created a new directory, let's call it Test and placed both .sty files, together with .layout file into it. Also, I saved my .lyx file into this directory.
3. In LyX: Document > Settings > Document Class > Local Layout, and then set "classicthesis.layout" from Test dir as my document class.
I tried that, but it gave the same results. I am using Lyx 2.0.0-3 and MikTex (v2.8 and 2.9, tried both on different computers).
meho_r wrote: AFAIK, LyX respects LaTeX path, so I'm not sure what went wrong in your case. All I can say is to try reconfiguring LyX (Tools > Reconfigure), then restart it and try compiling your document again.

Also, .sty files in working directory should take precedence over those installed in system dirs.
I thought so, too, and it does work this way if there is no package which also contains a file of the same name.
If I set MikTex to always ask me if there is a new package to be installed and manually delete classicthesis-preamble.sty inside the MikTex directory, the file from my working directory is used.
The workaround I finally settled with is modifying the .layout file so it requests "classicthesis-preamble_custom", which is just a renamed version inside my working directory.

Are you also using MikTex? Maybe the problem is not related to LyX. On the other hand, I could very well imagine this being some untested niche case, as the need to keep a copy of some standard package in the working directory seems to be fairly sparse.
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

classicthesis | LyX vs. LaTeX Search Path

Post by meho_r »

sheepd wrote:...

Are you also using MikTex? Maybe the problem is not related to LyX. On the other hand, I could very well imagine this being some untested niche case, as the need to keep a copy of some standard package in the working directory seems to be fairly sparse.
Maybe it is sparse, but it is crucial that things work as expected. E.g., you might want to make sure your documents are portable and compilable in future, so you decided to include all packages used in a doc in the same dir where your .lyx or .tex files reside (sort of backup; this is what bundledoc do). Having these packages later ignored will most certainly lead to serious issues.

I use TeXLive 2010, LyX version is 2.0. Now I wonder if this has something to do with MikTeX. Unfortunately, I cannot be of any help there.
PhilipPirrip
Posts: 10
Joined: Sat Sep 10, 2011 10:59 pm

Re: classicthesis | LyX vs. LaTeX Search Path

Post by PhilipPirrip »

This problem only exists in MiKTeX as its package manager installs and then uses system-wide classicthesis-preamble.sty. We are currently working on fixing this by making the preamble file a .tex and not a .sty any more (MiKTeX cares only about installing .sty's)
For now, changing the name of the classicthesis-preamble.sty, and modifying the line with the same name in classicthesis.layout should make things work.
sheepd
Posts: 4
Joined: Thu Jul 07, 2011 4:32 pm

Re: classicthesis | LyX vs. LaTeX Search Path

Post by sheepd »

I see, that's what I suspected. The workaround thing (which I think is the same I described in an earlier post) worked as desired.
One more thing I would suggest is putting the text-width settings (the \areaset stuff) also inside the preamble file, so it can be modified on a per-document basis.
I wrote my bachelor's thesis with classicthesis (preparing a postcard, by the way ;-)) and ended up using a sligthly larger type area, because otherwise my graphics and especially graphs were too small.
PhilipPirrip
Posts: 10
Joined: Sat Sep 10, 2011 10:59 pm

classicthesis | LyX vs. LaTeX Search Path

Post by PhilipPirrip »

sheepd wrote: One more thing I would suggest is putting the text-width settings (the \areaset stuff) also inside the preamble file, so it can be modified on a per-document basis.
I don't think this is ever going to happen, A.M. is very conservative on changing classicthesis.sty (for lots of reasons)
But what you can do is redefining the areaset commands in the LaTeX preamble of your LyX document(s):

Code: Select all

\areaset[current]{336pt}{750pt} % ~ 336 * factor 2 + 33 head + 42 \the\footskip 
\setlength{\marginparwidth}{7em}%
\setlength{\marginparsep}{2em}%
Preparing a postcard, by the way ;-)
I'm sure the author will be very glad to receive it ;)
Post Reply