8

During my searches, I found a couple of online images, which I doubt are produced with Latex - however, I found them immensely useful in understanding what is going on.

I'm pretty sure the images below were not produced automatically by latex - so I was wandering if there is a Latex package (or a method) - that would visualize demanded lengths with arrows (and possibly even length values?), like on the images below (apparently, adding them from web adds a copy on imgur; I've added the original links as well).

In the cases below, they are related to lists (enumerate/itemize) parameters - but I'd be interested in visualizing \parindent or \parskip in context of paragraphs as well.

Fig_enumerateS.jpg

listaparametrit.gif

listparams.png

Would there be anything out there that allows for similar visualization (possibly one that would work on a 'per page request' basis too; wouldn't want a 100 pg .pdf choke full with arrow vectors on every paragraph :))

4
  • 2
    Have a look at the package layouts. However the colored images are made by tikz or pstricks (I guess). May 13, 2012 at 9:59
  • Many thanks for that @MarcoDaniel - just looking at the package, looks like exactly what I need! Would you mind converting your comment to an answer, so I can accept it? Thanks again - cheers!
    – sdaau
    May 13, 2012 at 10:09
  • 1
    Not exactly what you're asking for, but if you use LuaTeX you can have a look at the lua-visual-debug package. It might give you a feeling where spaces/glues/... are. See tex.stackexchange.com/questions/50964/…
    – topskip
    May 17, 2012 at 8:17
  • Many thanks for that, @PatrickGundlach - never heard about that package before, and it has exactly the kind of visualization I want (but I also want marking of lengths as in layouts). Wish I could use lua-visual-debug with plain pdflatex - but it's great to know about it in any case... Cheers!
    – sdaau
    May 17, 2012 at 8:30

2 Answers 2

7

One default package to display length is the package layouts. It produces black/white images with represented lengths.

For example the example below produces the following images for list-environments.

enter image description here

\documentclass{article}
\usepackage{layouts}
\begin{document}
\listdiagram
\end{document}

However the coloured images are probably made by packages like TikZ or PSTricks.

1
  • Many thanks for that, @MarcoDaniel - great to have a minimal example! Cheers!
    – sdaau
    May 13, 2012 at 10:21
1

Well, just thought I might also post this snippet here - not quite like layouts, this snippet creates a command \showpagemarginstwh which only shows the page margins (based on \textwidth and \textheight) using LaTeX \put command:

\newlength{\tmvx}
\newlength{\tmvy}
\newlength{\curposy}
\newcommand{\showpagemarginstwh}{%
  \setlength{\curposy}{\dimexpr\pagetotal+\baselineskip}
  %\typeout{\the\curposy}
  \edef\mw{\getlength{\textwidth}}
  \edef\mh{\getlength{\textheight}}
  \edef\mp{\getlength{\parindent}}
  \setlength{\tmvx}{\textwidth}
  %\addtolength{\tmvx}{-\parindent} % use offset
  \setlength{\tmvy}{0.45\textheight}
  \edef\mvx{\getlength{\tmvx}}
  \edef\mvy{\getlength{\curposy}}
  %\begin{picture}(width,height)(x-offset,y-offset)
  \begin{picture}(0,0)(\mp,-\mvy)
    \put(0,0) {\line(1,0){\mw}}
    \put(0,0) {\line(0,-1){\mh}}
    \put(\mvx,0) {\line(0,-1){\mh}}
    \put(0,-\mh) {\line(1,0){\mw}}
  \end{picture}
}

Below is an MWE, which generates the following two pages of output:

test.png

The code (inline links: 1, 2, 3, 4, 5 ):

\documentclass{article}
% reminder: US letter: 596pt x 795pt

% https://tex.stackexchange.com/a/55852/2595
\newlength{\pagewidthA}\newlength{\pageheightA}
\setlength{\pagewidthA}{300bp}\setlength{\pageheightA}{400bp}

\newlength{\pagewidthB}\newlength{\pageheightB}
\setlength{\pagewidthB}{400bp}\setlength{\pageheightB}{500bp}

\usepackage{geometry}

\newcommand{\generatePageLayouts}{%
  \newgeometry{layoutwidth=\pagewidthA,layoutheight=\pageheightA,left=5mm,right=1mm,bottom=12mm,top=1mm}
  \savegeometry{LayoutPageA}

  \newgeometry{layoutwidth=\pagewidthB,layoutheight=\pageheightB,twoside,inner=2.5cm,outer=0.5cm,top=1.5cm,bottom=1.5cm}
  \savegeometry{LayoutPageB}
}

\newcommand{\switchToLayoutPageA}{%
  % doesn't include page sizes; so page size too:
  \pdfpagewidth=\pagewidthA \pdfpageheight=\pageheightA % for PDF output
  \paperwidth=\pagewidthA \paperheight=\pageheightA     % for TikZ
  \loadgeometry{LayoutPageA} % note; \loadgeometry may reset paperwidth/h!
  \paperwidth=\pagewidthA \paperheight=\pageheightA     % for TikZ
}

\newcommand{\switchToLayoutPageB}{%
  % doesn't include page sizes; so page size too:
  \pdfpagewidth=\pagewidthB \pdfpageheight=\pageheightB % for PDF output
  \paperwidth=\pagewidthB \paperheight=\pageheightB     % for TikZ
  \loadgeometry{LayoutPageB} % note; \loadgeometry may reset paperwidth/h!
  \paperwidth=\pagewidthB \paperheight=\pageheightB     % for TikZ
}

\usepackage{lipsum}


% https://tex.stackexchange.com/a/15002/2595
% to extract numbers from lengths:
% NOTE: \getlength gets numeric portion as pt always;
\makeatletter
  \newcommand*{\getlength}[1]{\strip@pt#1}
\makeatother

% https://tex.stackexchange.com/a/56058/2595
% https://tex.stackexchange.com/a/17813/2595
% http://www.latex-community.org/forum/viewtopic.php?f=9&t=13098
%
% display page margins based on \textwidth/height
% note \begin{picture} is treated like character;
% so we "lift" it from current position in page
% to make it align to margins
\newlength{\tmvx}
\newlength{\tmvy}
\newlength{\curposy}
\newcommand{\showpagemarginstwh}{%
  \setlength{\curposy}{\dimexpr\pagetotal+\baselineskip}
  %\typeout{\the\curposy}
  \edef\mw{\getlength{\textwidth}}
  \edef\mh{\getlength{\textheight}}
  \edef\mp{\getlength{\parindent}}
  \setlength{\tmvx}{\textwidth}
  %\addtolength{\tmvx}{-\parindent} % use offset
  \setlength{\tmvy}{0.45\textheight}
  \edef\mvx{\getlength{\tmvx}}
  \edef\mvy{\getlength{\curposy}}
  %\begin{picture}(width,height)(x-offset,y-offset)
  \begin{picture}(0,0)(\mp,-\mvy)
    \put(0,0) {\line(1,0){\mw}}
    \put(0,0) {\line(0,-1){\mh}}
    \put(\mvx,0) {\line(0,-1){\mh}}
    \put(0,-\mh) {\line(1,0){\mw}}
  \end{picture}
}



\begin{document}
  % here geometry layout L1 is instantiated;

  % generate page layouts first based on layoutwidth as page size;
  % don't switch actual page sizes yet:
  \generatePageLayouts{}

  %%% start with content

  % start with LayoutPageA (includes switching page size)
  \switchToLayoutPageA{}

  \lipsum[1]

  \showpagemarginstwh
  \lipsum[2]

  \clearpage

  \switchToLayoutPageB{}

  \lipsum[3]

  \showpagemarginstwh
  \lipsum[4]

  \clearpage

\end{document}

Image created with:

convert -density 150 -bordercolor LimeGreen -border 2 test.pdf[0] test1.png
convert -density 150 -bordercolor LimeGreen -border 2 test.pdf[1] test2.png
montage test1.png test2.png -geometry +2+2 -tile 2x1 test.png

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .