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

Torbjørn T.
  • 206,688
ginosap
  • 59

1 Answers1

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

Bernard
  • 271,350
  • @ginosap: I understand better now. See my updated answer. – Bernard Oct 02 '14 at 12:45
  • Very well, but you can put it all in a new command, so that typing \sx everything works? – ginosap Oct 02 '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 02 '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 02 '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 02 '14 at 14:29
  • Unfortunately I must ask excuse. I was too fast and quick and now I'm in confusion. I send you a picture of what I would do, without additional Latex packages. Is it possible? Thank you very much. http://imgur.com/uewfzav – ginosap Oct 02 '14 at 14:38
  • @ginospap: The specifications mentioned in your link are not quite clear to me. Should the scene action specification be ina narrower column than the dialogs column? – Bernard Oct 02 '14 at 16:24
  • This is the layout that I would get with Latex. Is it possible? I had thought to define new commands for CHARACTER and comments (in caps) Thanks for your great patience – ginosap Oct 03 '14 at 04:08
  • @ginosap: I completely rewrote my solution as I now understand better your requirements. Hope it's closer to what you want. – Bernard Oct 03 '14 at 21:11
  • Great job! One last thing: If I want in the future transform the font in speci from uppercase to italic? Thanks! – ginosap Oct 04 '14 at 12:56
  • @ginosap: Just replace \MakeTextUppercase{#1} with \textit{#1} in the preamble. Of course, all numeric values can be adjusted to your taste/needs. – Bernard Oct 04 '14 at 13:08
  • Wonderful! Now I need to study your solution. Thank you for your patience. – ginosap Oct 04 '14 at 13:36
  • You're welcome. It's based on simple plain TeX macros. – Bernard Oct 04 '14 at 13:39
  • First of all thanks again for your work. I would have only small things to get to the top:
    • How can I adjust the distance between the end of speci and the beginning of a new character?
    • I would like to use the command \include to get more files attached to the preamble, you can enter commands \def\Marchese{\character{Marchese}} within individual files and after \begin? Thanks a lot!
    – ginosap Oct 05 '14 at 13:32
  • @Ginosap: I introduced a \postspeciskip length, that defaults to 1.5\baselineskip and that can be changed through \postspeciskip=…. And yes, you can have a main file and included files, with the shortcuts for characters defined in the included files. See my updated answer. – Bernard Oct 05 '14 at 15:37
  • You are simply the best! Great! – ginosap Oct 05 '14 at 19:15
  • One last thing: How do I set the height of fonts with pt (like 12pt, 14pt) without using Large/LARGE, etc. In every single part (character, etc). Thanks – ginosap Oct 20 '14 at 11:32
  • You have to write \fontsize{x pt}{y pt}\selectfont, where x pt, is the xheight, say 14pt, y pt is the interlineskip (not sure of the exact word, but normally it is ~ 1.2 times xheight). – Bernard Oct 20 '14 at 15:26
  • Hi. Is possible to align character name to center? Like this image: http://imgur.com/M9T7SoF – ginosap Nov 24 '14 at 14:17
  • It's perfectly possible. Please see my modified answer. Is that like you want? – Bernard Nov 24 '14 at 19:56
  • I ask one thing that perhaps it is impossible. When I have a sentence too long(like \Conte .....), I would like to remain on the same page and that is not divided into two pages. If it is too long, the entire phrase should go on the next page. Is it possible? – ginosap Dec 29 '14 at 06:31
  • Another thing: If I want to insert a word within the \begin{center} environment and before I have a \speci, the word is not centered on the page but in the paragraph of \speci. How can you make to center the word? – ginosap Jan 12 '15 at 11:15
  • @ginosap: there is a solution to prevent paragraph breaking at page breaks. See my updated answer. For the other problem (center environment after a \speci, I can't reproduce it. Do you have a minimal example? – Bernard Jan 14 '15 at 10:26
  • Thank you. Unfortunately I changed the tex file according to your suggestions and as I studied the commands that you sent me. I attach the master file and the file includes. On the second page you can see the problem by \begin{center}. – ginosap Jan 14 '15 at 19:07
  • I don't see any file includes?! – Bernard Jan 14 '15 at 19:13
  • http://1drv.ms/1IKUchp – ginosap Jan 14 '15 at 19:20
  • http://1drv.ms/1IKUmoS – ginosap Jan 14 '15 at 19:20
  • Excuse me. I don't still unsterstand how work this forum... Please don't get angry – ginosap Jan 14 '15 at 19:21
  • I'm not angry… :o). Change your definition of \centro to:
    \newcommand\centro[1]{\hangindent=0pt\fontsize{15pt}{16pt}\selectfont\begin{center}#1\end{center}}. It works now.
    – Bernard Jan 15 '15 at 02:50
  • Thank you very much. Now everything is ok. When you have time could you direct me to a book, a guide, which let me see all the commands you suggested? Thanks again. – ginosap Jan 15 '15 at 08:27
  • @ginosap: I mainly defined simple plain TeX commands based on hangindent. Actually I don't know plain TeX very well. The little I know comes from Victor Eijkhout's very good TeX by Topic, which is part of TeX Live, and that you also can find on CTAN. – Bernard Jan 15 '15 at 22:09
  • Good Morning. I see that in certain definitions there are ante and post spacings. You can also set in "character"? – ginosap Jul 15 '15 at 11:27
  • @ginosap: I only see a \postpreciskip that I defined. You would like to have similar definitions for pre- and post-character lengths, that might adjust at will in the preamble? – Bernard Jul 15 '15 at 14:55
  • Yes, dear Bernard! – ginosap Jul 15 '15 at 15:07
  • Hi! In my code I'll want to put some text within \speci or within another command. But this text have the same font of \speci or the element before. It's possible to "reset" the font after \speci or another element, so the independent insert text have the "standard" font? Thank you. – ginosap Oct 05 '15 at 14:07
  • The new discussion link : http://tex.stackexchange.com/questions/271384/build-theatre-script-in-latex – ginosap Oct 09 '15 at 15:25