Generalrendering Windows path names in constant width in a table

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
lnewton
Posts: 17
Joined: Mon Mar 31, 2008 3:01 pm

rendering Windows path names in constant width in a table

Post by lnewton »

Is there a package that will assist me with rendering
Windows path names properly? I need them to appear in
constant width font, and within a longtable cell.

\path is almost but not quite up to the job. For one thing,
\path swallows spaces, so for instance, this:

\path|C:\My Stuff\My Document.doc|

will appear as C:\MySutff\MyDocument.doc in printed output.
For another, I can't seem to use \path in the cell of a
longtable.

Not long ago I had to create an appendix that showed a list
of nearly 1,000 Windows file path names within a longtable,
itself within a landscape environment. Some of these path
names were so long that even using \scriptsize in landscape
they barely made it on the page.

After considerable monkeying with it, I was ultimately
obliged to put it all inside \texttt{}, and then had to do
mass edits to render all '\' characters wyth \symbol, and to
escape spaces, underbars, ampersands, and a few other things
as well. Way too much trouble.

Surely I am not the first person to have encountered this
problem; there must be a much easier solution. Can someone
help me with this, as it appears to be something that will
come up from time to time in my work.

A fragment example of how I had to deal with it follows.
Consider setting this file path:

C:\Documents and Settings\Joe Blow's Stuff\Bits & Pieces.jpg

\scriptsize
\begin{landscape}
\begin{longtable}{|rrrl|}
\hline
% stuff deleted
\multicolumn{4}{|l|}{\texttt{C:\symbol{'134}Documents and Settings\symbol{'134Joe Blow's Stuff\symbol{'134}Bits \& Pieces.jpg}}\\
% more stuff deleted
\end{longtable}
\end{landscape}

There's got to be a better way.
Lynn

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

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Re: rendering Windows path names in constant width in a table

Post by Stefan Kottwitz »

Hi lnewton,

is your question still unsolved?

I remember that I tested your code fragment and tried to find a solution. The first choice for me would be verbatim text/ environments. I knew there might be problems with verbatim environment inside tables, but there are packages like examplep that can be used for that. I also remember that examplep was working well, it only showed an oddity with & inside your path name.

If your are still interested in talking about a solution, let us know.

Stefan
lnewton
Posts: 17
Joined: Mon Mar 31, 2008 3:01 pm

Re: rendering Windows path names in constant width in a table

Post by lnewton »

Yes, I would like very much to see a handy long-term solution
to this problem, because in my work it is liable to come up
rather frequently that we have to render long Windows file
names in constant width font within a table.

I'm not familiar with the packages you cited. I will meanwhile
look at those.
Lynn
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

rendering Windows path names in constant width in a table

Post by Stefan Kottwitz »

Hi lnewton,

here's one small example:

Code: Select all

\documentclass{article}
\usepackage{pdflscape,examplep,longtable}
\begin{document}
\PVerb{C:\Documents and Settings\Joe Blow's Stuff\Bits & Pieces.jpg}
\begin{longtable}{|rrrl|}
\hline
\multicolumn{4}{|l|}{\PVerb{C:\Documents and Settings\Joe Blow's Stuff\Bits & Pieces.jpg}}\\
1 & 2 & 3 & 4\\
\hline
\end{longtable}
\end{document}
examplep is doing quite well, the only problem I found was the & sign in pathnames inside tables.

Stefan
lnewton
Posts: 17
Joined: Mon Mar 31, 2008 3:01 pm

Re: rendering Windows path names in constant width in a table

Post by lnewton »

Wow! Meanwhile, I ran a couple of examples of my own after skimming the
examplep documentation and had similar results.

I believe the instances where & appears a name will be few enough that we
can manage it, although it will happen, so I'll look in the documentation
for an example to get over that hump, too.

Thank you very much for that pointer and example. It will save us much work
in future days.
Lynn
Post Reply