Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm redacting a document, adding the correct tags and syntax for LaTeX. I have come with a "problem" with margins. Or rather with environments that answer differently to margins, making them appear as not organized and consistent. It's not a fatal error, but a good looking document is as important as the content.

I have two choices now.

  1. The first one is setting the margins so that the content goes in the center (as usual), while the list items, for example, go outside of the document content. Something like this:

    Outside

  2. The second one instead, positions everything inside the document content line, strictly within the margins. The list items are aligned to the right, in order to give the list a better shape (this is already done by the current enumerate and itemize environments):

    Inside

My questions are: which solution is the best, considering the current standards? What about the one that is easier to implement? How is the proper way to proceed doing this (in other words: are there packages, what syntax, etc)?

share|improve this question
    
I'd say that any answers to your question should depend importantly on the nature of the material that's in the itemized environment and how the itemized material relates to the preceding matter. Basically, is the itemized material mainly an elaboration of the preceding stuff or is it something else? If it's mainly an elaboration, I'd say the second style you show is more appropriate. –  Mico Jun 27 '12 at 17:22
    
@Mico I'd like to use one for the whole document. I feel that using two styles might be confusing (although theoretically it would be more appropriate to do so, for the reasons you said). –  Alenanno Jun 27 '12 at 17:24
    
Your first choice is "dangerous" if you have two (or more) paragraphs in last item: How to know if second paragraph is in the last item of your enumeration or a normal paragraph following your enumeration ? –  Paul Gaborit Jun 29 '12 at 15:34

3 Answers 3

up vote 4 down vote accepted

One way to get what you want (second option) is to define the environment with an argument that contains the widest entry:

\newlength{\xdescwd}
\newenvironment{xdesc}[1]
  {\settowidth{\xdescwd}{\textbf{#1:}}%
   \begin{description}[leftmargin=\dimexpr\xdescwd+.5em\relax,
     labelindent=0pt,labelsep=.5em,
     labelwidth=\xdescwd,align=right]}
  {\end{description}}

Here's the complete example

\documentclass[12pt]{article}
\usepackage[a4paper, margin=2cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[shortlabels]{enumitem}
\usepackage{graphicx}
\usepackage{pifont}
\usepackage{titlesec}
\usepackage[spanish]{babel}

\newlength{\xdescwd}
\newenvironment{xdesc}[1]
  {\settowidth{\xdescwd}{\textbf{#1:}}%
   \begin{description}[leftmargin=\dimexpr\xdescwd+.5em\relax,
     labelindent=0pt,labelsep=.5em,
     labelwidth=\xdescwd,align=right]}
  {\end{description}}

\setlist[enumerate]{itemsep=-1mm}
\setlist[itemize]{itemsep=-1mm}

\begin{document}

En un contexto determinado, las palabras poseen, además de su significado literal, también una dimensión intencional. Un texto es la manifestación lingüística de la intención del emisor dirigida a un receptor. Si consideramos, pues, los actos ilocutivos implicados, un texto cumplirá funciones diferentes.

La función textual es el efecto de los textos en una situación comunicativa según los objetivos que queremos alcanzar. Un texto puede desempeñar las siguientes funciones:

\begin{xdesc}{Representativa}% argument is the widest label
\item[Representativa:] llamada también asertiva, cuando se afirma o se anuncia algo que se considera verdadero.
\item[Informativa:] cuando se presenta algo de manera neutra, sin énfasis que pueda denotar emotividad, como por ejemplo un titular de una noticia.
\item[Prescriptiva:] cuando se establecen normas. En la legislación, por ejemplo, se emplean formas modales deónticas (deber + infinitivo) para expresar una orden.
\item[Persuasiva:] cuando se trata de convencer al interlocutor
\item[Comisiva:] cuando se promete, jura, ofrece, etc.
\item[Fática:] cuando el emisor se centra en el interlocutor y procura mantener el contacto con él, como por ejemplo “Oye…”
\item[Expresiva:] cuando el emisor se alegra, agradece, felicita.
\end{xdesc}

\end{document}

enter image description here


With a two-pass approach one can avoid guessing at the widest label:

\documentclass[12pt]{article}
\usepackage[a4paper, margin=2cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[shortlabels]{enumitem}
\usepackage[spanish]{babel}

\newlength{\xdescwd}
\usepackage{environ}
\makeatletter
\NewEnviron{xdesc}{%
  \vbox{\hbadness=\@M \global\xdescwd=0pt
    \def\item[##1]{%
      \settowidth\@tempdima{\textbf{##1}:}%
      \ifdim\@tempdima>\xdescwd \global\xdescwd=\@tempdima\fi}
  \BODY}
  \begin{description}[leftmargin=\dimexpr\xdescwd+.5em\relax,
    labelindent=0pt,labelsep=.5em,
    labelwidth=\xdescwd,align=left]\BODY\end{description}}
\makeatother

\begin{document}

En un contexto determinado, las palabras poseen, además de su significado literal, también una dimensión intencional. Un texto es la manifestación lingüística de la intención del emisor dirigida a un receptor. Si consideramos, pues, los actos ilocutivos implicados, un texto cumplirá funciones diferentes.

La función textual es el efecto de los textos en una situación comunicativa según los objetivos que queremos alcanzar. Un texto puede desempeñar las siguientes funciones:

\begin{xdesc}
\item[Representativa:] llamada también asertiva, cuando se afirma o se anuncia algo que se considera verdadero.
\item[Informativa:] cuando se presenta algo de manera neutra, sin énfasis que pueda denotar emotividad, como por ejemplo un titular de una noticia.
\item[Prescriptiva:] cuando se establecen normas. En la legislación, por ejemplo, se emplean formas modales deónticas (deber + infinitivo) para expresar una orden.
\item[Persuasiva:] cuando se trata de convencer al interlocutor
\item[Comisiva:] cuando se promete, jura, ofrece, etc.
\item[Fática:] cuando el emisor se centra en el interlocutor y procura mantener el contacto con él, como por ejemplo “Oye…”
\item[Expresiva:] cuando el emisor se alegra, agradece, felicita.
\end{xdesc}

\end{document}

This actually requires typesetting the environment twice: one for gathering the label widths, the second time for the real typesetting.

share|improve this answer
    
Thank you egreg! I'll take yours for now but I'll reserve my right to ask you clarifications later. One thing for now: why did you add the spanish package? Is it because you needed it? –  Alenanno Jun 29 '12 at 14:56
    
@Alenanno Without spanish hyphenation is incorrect. –  egreg Jun 29 '12 at 14:58
    
I get two errors. One is Something's wrong--perhaps a missing \item. and the other one is Lonely \item--perhaps a missing list environment.... Even trying your code alone and not my whole document. –  Alenanno Jun 29 '12 at 15:04
    
@Alenanno Sorry, copied the wrong code: the argument to xdesc is missing. Fixed. –  egreg Jun 29 '12 at 15:09
    
Don't worry! :) Is the argument necessary? I mean, does it help the list to "check" the correct width or something? –  Alenanno Jun 29 '12 at 15:32

presumably you're redacting for someone else.

is there a publisher involved? does the publisher have a preferred style? that's the first consideration.

if no guidance there, look at the "item labels". how wide are they relative to the margin? it's not a good idea to get too close either to the outside edge (where something might get cut off) or to the binding (where something might be obscured). if they're really wide, would it be permissible to set them on multiple lines (being careful to align the top baselines), and what do you do if the number of lines required by the label is greater than the number of lines in the text?

if you consider setting everything within the main text block, you still need to consider the width of the labels, as what you do will affect the width of the area available for the text. again, with wide labels, do you look at a multi-line approach (as for the in-the-margin case) or do you just decide on a decent width for the text, and, if any label is wider than the available space, let it encroach on the text area, and start the actual text on a new line?

this is pretty subjective, and i'd start by looking for the "worst case" in the job. (there may be several "worst cases" -- the absolute widest label; a wide label with short text; labels just wide enough to make the decision about how much space to leave between label and text a nasty one.) if you can handle those successfully, the rest should be relatively straightforward.

one thing i would recommend though is that (as you point out) a uniform approach throughout the job will produce a more professional looking result than something that can be perceived as random.

share|improve this answer
    
No, I'm redacting for me. :) I simply copied the content from a normal doc to a TeX document and now I'm fixing it. –  Alenanno Jun 27 '12 at 17:52
1  
if the "only" person you have to please is yourself, then see if you can find a similar document that you like the looks of, and follow its lead. create a small test document with the "good bad examples" you've identified, and try a few different approaches. and it never hurts to look at what "the usual suspects" have to say -- chicago, bringhurst, tufte, ... good luck. –  barbara beeton Jun 27 '12 at 18:05
    
How would you implement the second solution? If you don't know how, could you point me at some guide? –  Alenanno Jun 28 '12 at 9:35
    
by the "second solution", i believe you mean working within the established text width, and creating a structure similar to the description environment. although i really prefer to work with actual examples, i'll try to put something together with invented material. i'm sure it's been done already, but i'm not sure where i might find it quickly. (if someone else does know, please feel free to add an answer with code or a pointer.) –  barbara beeton Jun 28 '12 at 12:11

I decided for the second option. My reasons are that (1) the margins would be too narrow for long labels to fit and (2) the first option would look ugly.

Using the second solution from egreg's answer, then this scheme in Marco Daniel's answer with the add of this page, without forgetting some tweaking, I came up with a solution:

\documentclass[12pt]{article}
\usepackage[a4paper, margin=2cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[shortlabels]{enumitem}
\usepackage{graphicx}
\usepackage{pifont}
\usepackage{titlesec}

\newenvironment{xdesc}[0]
  {\begin{description}[leftmargin=4cm,
     labelindent=0pt,labelsep=1cm,
     labelwidth=3cm,align=right]}
  {\end{description}}

\setlist[enumerate]{itemsep=-1mm}
\setlist[itemize]{itemsep=-1mm}

\begin{document}

En un contexto determinado, las palabras poseen, además de su significado literal, también una dimensión intencional. Un texto es la manifestación lingüística de la intención del emisor dirigida a un receptor. Si consideramos, pues, los actos ilocutivos implicados, un texto cumplirá funciones diferentes.

La función textual es el efecto de los textos en una situación comunicativa según los objetivos que queremos alcanzar. Un texto puede desempeñar las siguientes funciones:

\begin{xdesc}
\item[Representativa:] llamada también asertiva, cuando se afirma o se anuncia algo que se considera verdadero.
\item[Informativa:] cuando se presenta algo de manera neutra, sin énfasis que pueda denotar emotividad, como por ejemplo un titular de una noticia.
\item[Prescriptiva:] cuando se establecen normas. En la legislación, por ejemplo, se emplean formas modales deónticas (deber + infinitivo) para expresar una orden.
\item[Persuasiva:] cuando se trata de convencer al interlocutor
\item[Comisiva:] cuando se promete, jura, ofrece, etc.
\item[Fática:] cuando el emisor se centra en el interlocutor y procura mantener el contacto con él, como por ejemplo “Oye…”
\item[Expresiva:] cuando el emisor se alegra, agradece, felicita.
\end{xdesc}

\end{document}

which produces the following output:

output

I have still problems because the first item crosses the margin line and the item-explanations are too spaced, but it's a start.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.