From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Request for suggestions including source code Date: Wed, 04 May 2011 17:44:41 -0400 Message-ID: <6167.1304545481@alphaville.americas.hpqcorp.net> References: <4DC1BCE7.8060503@sift.info> <3B495FCF-216C-4B81-BC13-DC74B8C401B9@tsdye.com> Reply-To: nicholas.dokos@hp.com Return-path: Received: from eggs.gnu.org ([140.186.70.92]:50053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QHjsE-0003PN-Kc for emacs-orgmode@gnu.org; Wed, 04 May 2011 17:44:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QHjsD-0005WT-9C for emacs-orgmode@gnu.org; Wed, 04 May 2011 17:44:46 -0400 Received: from g5t0007.atlanta.hp.com ([15.192.0.44]:20728) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QHjsD-0005WO-5d for emacs-orgmode@gnu.org; Wed, 04 May 2011 17:44:45 -0400 In-Reply-To: Message from "Thomas S. Dye" of "Wed, 04 May 2011 11:13:06 -1000." <3B495FCF-216C-4B81-BC13-DC74B8C401B9@tsdye.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "Thomas S. Dye" Cc: nicholas.dokos@hp.com, Org Mode , rpgoldman@sift.info Thomas S. Dye wrote: > Aloha Robert, > > Have a look at the listings and minted packages. You can specify font size on a per-document or per-language basis. I believe listings has an option to wrap long lines (don't remember this for minted, though). > > The instructions here might be helpful: > > http://orgmode.org/worg/org-tutorials/org-latex-export.html#sec-12_2 > > hth, > Tom > > On May 4, 2011, at 10:53 AM, Robert Goldman wrote: > > I have a document that has big chunks of included source code. > Unfortunately, when this is typeset in LaTeX, it typically blows past > the right margin. I find it quite difficult to determine how many > characters I get in a monospace line in LaTeX, and it seems like LaTeX > won't give me enough to fit in plausible blocks of source code. > > Does anyone have a solution to this? Any way to tell org-mode to shrink > the fontsize when exporting code examples to LaTeX? More condensed font > to use for typewriter when exporting to LaTeX? Other tricks of the trade? > > Seems like many would have encountered this problem. > > Many thanks, > r > > Tom provides the practical answers, I go for the frivolous ones :-) : the following latex program will give you the text width of the page: --8<---------------cut here---------------start------------->8--- \documentclass{article} \begin{document} \the\textwidth \end{document} %%% Local Variables: %%% mode: latex %%% TeX-master: t %%% End: --8<---------------cut here---------------end--------------->8--- I get 345.0pt (but you can use geometry.sty to change it). Let's say we want to use cmtt10 (at its design size of 10pt, i.e. not scaled up or down). The character sizes of this font can be obtained from the TFM file. An easy way to get them in human-readable form is to use tftopl: tftopl /usr/share/texmf-texlive/fonts/tfm/public/cm/cmtt10.tfm | grep CHARWD will give you the character widths as fractions of the design size. Since this is a fixed-width font, all widths are the same: (CHARWD R 0.524996) So the width of each character in points is: 0.524996 * design size = 5.24996pt and you can accommodate floor(345.0 / 5.24996) = 65 characters per line. So there you have it: a frivolous exercise, almost completely OT for the list and an almost useless answer[fn:1]. Nick Footnotes: [fn:1] I know: I have no life -- but I rather enjoyed it...