0

I would like to create a new command in LaTeX that aligns the text right and left (see example below). Only that I wish the text column were as large as half page.

\documentclass[a4paper,10pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage[a4paper, nohead, nofoot, top=2cm, bottom=2cm, left=2cm, right=2cm]{geometry}
\newcommand\sx{\fontfamily{lmss}\Large\flushright}
\newcommand\dx{\fontfamily{lmss}\Large\flushleft}
\begin{document}
\sx Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
\bigskip
\dx Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
\end{document}

Desired output:

enter image description here

2
5

Now that I understand better your problem, thanks to your link, I can propose this, that seems to fulfill all the requirements.

I define a \character command that typesets the characters names uppercase and defines the value of hangindent for the subsequent text, which can have several paragraphs.

I also define a \speci command. There is only two constraints: new paragraphs, if any, are to be introduced with the plain TeX command \endgraf, and newlines with the \newline command, not in the usual way. A \postspeciskip length (defaults to 1.5\baselineskip) can be used to set the distance from specifications to dialogs text.

Acts and scenes are considered \chapters and \sections. They are conveniently formatted with the help of the titlesec package. Some part of the coding would be simpler if the requirement for specifications were smallcaps instead of uppercase.

If you want paragraphs not to be cut at page breaks, you can add this line to the preamble:

\interlinepenalty=10000 \parskip0pt plus \baselineskip

One can include files and shortcuts for the different characters can be defined in the included files.

Here is an example (with the beginning of Goldoni's La Locandiera).

Main file:

\documentclass[a4paper,11pt]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[italian]{babel}
\usepackage[noheadfoot, margin=2cm, showframe, nomarginpar]{geometry}
\usepackage{textcase}
\usepackage[explicit]{titlesec}

\newlength{\postspeciskip}
\postspeciskip = 1.5\baselineskip

\newcommand\character[1]{\par\everypar{\hangindent=0.3\linewidth\hangafter=1}\parskip=0.667\baselineskip plus
2pt\large\makebox[0.3\linewidth][r]{\MakeTextUppercase{#1}:\hskip0.1\linewidth }}

\newcommand\speci[1]{\everypar{\hangindent=0.42\linewidth\hangafter=0}\parskip=0.667\baselineskip plus
2pt\large\raggedright\textit{#1}\vskip\postspeciskip}%

\titleformat{\chapter}[block]{\centering\bfseries\LARGE}{\MakeTextUppercase\chaptername~\thechapter}{1em}{#1}
\titlespacing*{\chapter}{0pt}{2\baselineskip}{3\baselineskip}
\renewcommand\thechapter{\Roman{chapter}}
\newcommand\act[1][]{\chapter{#1}}

\setlength\fboxsep{0pt}
\titleformat{\section}[hang]{\Large}{\makebox[0.29\linewidth][l]{\MakeTextUppercase{\chaptername~\thechapter}} \makebox[0.1\linewidth][l]{\MakeUppercase{\sectionname~\thesection}\qquad}} {1em}{#1}
\titlespacing*{\section}{0pt}{1\baselineskip}{1\baselineskip}
\renewcommand\thesection{\arabic{section}}
\newcommand\scene[1][]{\section{#1}}

\AtBeginDocument{\def\chaptername{atto}\def\sectionname{scena}}
\setlength\parindent {0pt}%
\interlinepenalty = 1000\parskip0pt plus \baselineskip
\begin{document}

\sffamily
\include{1stact}

\end{document} 

Included file: (1stact.tex)%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\Marchese{\character{Marchese}}
\def\Conte{\character{Conte}}
\def\Fabrizio{\character{Fabrizio}}
%%%%%%%%%%%%%%%%%%%%%%%%%    \act

\scene
\speci{Sala di locanda.
\endgraf
Il Marchese di Forlipopoli ed il Conte d’Albafiorita}

\Marchese Fra voi e me vi è qualche differenza.
\Conte Sulla locanda tanto vale il vostro denaro, quanto vale il mio.
\Marchese Ma se la locandiera usa a me delle distinzioni, mi si convengono più che a voi.
\Conte Per qual ragione?
\Marchese Io sono il Marchese di Forlipopoli.
\Conte Ed io sono il Conte d’Albafiorita.
\Marchese Sì, Conte! Contea comprata.
    \Conte Io ho comprata la contea, quando voi avete venduto il marchesato.
 \Marchese Oh basta: son chi sono, e mi si deve portar rispetto.
 \Conte Chi ve lo perde il rispetto? Voi siete quello, che con troppa libertà parlando...
 \Marchese Io sono in questa locanda, perché amo la locandiera. Tutti lo sanno, e tutti devono rispettare una giovane che piace a me.
 \Conte Oh, questa è bella! Voi mi vorreste impedire ch’io amassi Mirandolina? Perché credete ch’io sia in Firenze? Perché credete ch’io sia in questa locanda?
 \Marchese Oh bene. Voi non farete niente.
 \Conte Io no, e voi sì?
 \Marchese Io sì, e voi no. Io son chi sono. Mirandolina ha bisogno della mia protezione.
 \Conte Mirandolina ha bisogno di denari, e non di protezione.
 \Marchese Denari? ... non ne mancano.
 \Conte Può essere che lo voglia sposare. Non sarebbe cosa mal fatta. Sono sei mesi che è morto il di lei padre. Sola una giovane alla testa di una locanda si troverà imbrogliata. Per me, se si marita, le ho promesso trecento scudi.

\dotfill

\scene

\speci{Fabrizio e detti.}

\Fabrizio Mi comandi, signore. (Al Marchese.)
\Marchese Signore? Chi ti ha insegnato la creanza?
\Fabrizio La perdoni.
\Conte Ditemi: come sta la padroncina? (A Fabrizio.)
\Fabrizio Sta bene, illustrissimo.

\dotfill 

enter image description here

enter image description here

36
  • @ginosap: I understand better now. See my updated answer.
    – Bernard
    Oct 2 '14 at 12:45
  • Very well, but you can put it all in a new command, so that typing \sx everything works?
    – ginosap
    Oct 2 '14 at 13:27
  • @ginosap: See my updated answer. Note that the commands and relevant text must be enclosed in braces (that's why an environment would be better).
    – Bernard
    Oct 2 '14 at 13:49
  • Thank you a lot. Your sentence: Perhaps it would be better to define and use environments rather than commands Is it possible to include environments in the commands?
    – ginosap
    Oct 2 '14 at 14:01
  • It is possible for commands with arguments, but here you have switches, their scope is unlimited, unless it's enclosed within braces or an environment. Or you'll have to define another switch that brings you back to the default layout.
    – Bernard
    Oct 2 '14 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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