5

I want to simplify the writing of this content, which should appear tabulated.

I've written two macros to indent and colored and . And I want to avoid having to always write \par at the end of each line.

How could I make the \par to be inserted at the end of the macros ... and furthermore, at the end of the macro \sr to insert two line breaks.

Or ... simplifying further, could I insert the colored and from a macro or environment, without having to type them in the text?

This is my code:

% !TeX program = lualatex
\documentclass[10pt,twoside,openany,showtrims]{memoir}
%\usepackage[T1]{fontenc}
%\usepackage[spanish]{babel}
\usepackage{fontspec}
\usepackage{polyglossia}
\setdefaultlanguage{spanish}
\usepackage{ucs}
\usepackage{csquotes} 
\usepackage{xcolor}  
\usepackage{needspace}  
\usepackage{lipsum} 
\setcounter{tocdepth}{4}
\settrimmedsize{6in}{9in}{*}
\setmainfont{FreeSerif}

\newfontfamily\fsfont{FreeSerif}
\newfontfamily\alterfont{FreeSans}

\newcommand{\txtred}[1]{\textcolor{red}{#1}}
\newcommand{\h}{\hspace{5mm}}
\newcommand{\hl}{\hspace{10mm}}
\newcommand{\sv}{\txtred}
\newcommand{\sr}{\txtred}

\newenvironment{readbody}{%
    \alterfont
}%

\begin{document}
    \mainmatter
    \begin{readbody}
        \sv ℣.  \h Señor, enséñame tus caminos,\par
                \hl instrúyeme en tus sendas: \par
                \hl haz que camine con lealtad;\par
                \hl enséñame, porque tú eres mi Dios y Salvador. \sr ℟.\par \par 
                %Need two lines skip here
        \sv ℣.  \h Recuerda, Señor, que tu ternura\par
                \hl y tu misericordia son eternas;\par
                \hl acuérdate de mí con misericordia,\par
                \hl por tu bondad, Señor. \sr ℟.\par \par                        
                %Need two lines skip here
        \sv ℣.  \h El Señor es bueno y es recto,\par
                \hl enseña el camino a los pecadores;\par
                \hl hace caminar a los humilles con rectitud,\par
                \hl enseña su camino a los humildes. \sr ℟.
    \end{readbody}  
\end{document}

And the output:

enter image description here

I want simplify, writing this:

\begin{readbody}
    \sv ℣.  \h Señor, enséñame tus caminos,
            \hl instrúyeme en tus sendas: 
            \hl haz que camine con lealtad;
            \hl enséñame, porque tú eres mi Dios y Salvador. \sr ℟.
    \sv ℣.  \h Recuerda, Señor, que tu ternura
            \hl y tu misericordia son eternas;
            \hl acuérdate de mí con misericordia,
            \hl por tu bondad, Señor. \sr ℟.
    \sv ℣.  \h El Señor es bueno y es recto,
            \hl enseña el camino a los pecadores;
            \hl hace caminar a los humilles con rectitud,
            \hl enseña su camino a los humildes. \sr ℟.
\end{readbody}

And giving this:

enter image description here

I am starting with LaTeX. So I'm open to suggestions for better ways to do this, keeping in mind that one of my goals in this particular case is to simplify the writing.

3
  • 1
    Is the 5mm and 10mm spacing here required or is the intention that the left edge of the text is all aligned? Commented Jan 26, 2021 at 21:23
  • @DavidCarlisle I added 5mm and 10mm arbitrarily, but the intention is for the text to appear aligned.
    – A. Cedano
    Commented Jan 26, 2021 at 21:26
  • 2
    currently it appears disturbingly unaligned, which is why I asked:-) Commented Jan 26, 2021 at 21:27

2 Answers 2

5

enter image description here

I have used \obeylines and \everypar to add the items automatically, note that your environment definition was missing the second argument with the end code.

% !TeX program = lualatex
\documentclass[10pt,twoside,openany,showtrims]{memoir}
%\usepackage[T1]{fontenc}
%\usepackage[spanish]{babel}
\usepackage{fontspec}
\usepackage{polyglossia}
\setdefaultlanguage{spanish}
% \usepackage{ucs}
\usepackage{csquotes} 
\usepackage{xcolor}  
\usepackage{needspace}  
\usepackage{lipsum} 
\setcounter{tocdepth}{4}
\settrimmedsize{6in}{9in}{*}
\setmainfont{FreeSerif}

\newfontfamily\fsfont{FreeSerif}
\newfontfamily\alterfont{FreeSans}

\newcommand{\txtred}[1]{\textcolor{red}{#1}}
\newcommand{\sv}{\txtred}
\newcommand{\sr}{\txtred}

\makeatletter
\catcode13\active %
\newenvironment{readbody}{%
    \alterfont%
    \setlength\parskip{\bigskipamount}%
    \setlength\parindent{0pt}%
    \setlength\leftskip{10mm}%
    \catcode13\active %
    \def^^M{\@ifnextchar^^M{\par}{\@ifnextchar\end{\ifhmode\par\fi}{\ifhmode\\\fi}}}%
    \def\par{~\sr ℟.\endgraf}%
    \everypar{\makebox[0pt]{\sv ℣.\qquad}}%
}{}%
\catcode13=5 %
\makeatother

\begin{document}
    \mainmatter
    \begin{readbody}
         Señor, enséñame tus caminos,
         instrúyeme en tus sendas: 
         haz que camine con lealtad;
         enséñame, porque tú eres mi Dios y Salvador.

          Recuerda, Señor, que tu ternura
          y tu misericordia son eternas;
          acuérdate de mí con misericordia,
          por tu bondad, Señor.

          El Señor es bueno y es recto,
          enseña el camino a los pecadores;
          hace caminar a los humilles con rectitud,
          enseña su camino a los humildes.

    \end{readbody}  
\end{document}
7
  • Even simpler! I am loving the way things can be simplified with LaTeX! Many thanks David!
    – A. Cedano
    Commented Jan 26, 2021 at 22:50
  • I have a question regarding your code: If I implement your solution I would no longer need the macros sv and sr in context. I have tried to change this: ~\sr ℟.\endgraf for this ~\txtred ℟.\endgraf and this \sv ℣.\qquad for this \txtred ℣.\qquad and it works apparently. Will there be a problem if I leave it like this?
    – A. Cedano
    Commented Jan 26, 2021 at 23:00
  • @A.Cedano no that's fine. The one bad part of this code is that it requires a blank line at the end before the \end{..} that would be fixable but a bit tricky so not tonight. Commented Jan 26, 2021 at 23:02
  • Ok, I see. May I ask about this maybe tomorrow in a new question?
    – A. Cedano
    Commented Jan 26, 2021 at 23:05
  • @A.Cedano not worth a new question, I may add something here later (well of course you are free to ask any question you want:-) Commented Jan 26, 2021 at 23:26
3

This is a solution that can be right for you. I changed your definition of \sv and \rv and redefined the readbody environment.

\documentclass[10pt,twoside,openany,showtrims]{memoir}
\settrimmedsize{6in}{9in}{*}
\usepackage{fontspec}
  \setmainfont{FreeSerif}
  \newfontfamily\fsfont{FreeSerif}
  \newfontfamily\alterfont{FreeSans}
\usepackage{polyglossia}
  \setdefaultlanguage{spanish}
\usepackage{xcolor}  

\newcommand{\sv}{\item\textcolor{red}{℣}.\quad}
\newcommand{\sr}{\textcolor{red}{℟}.\medskip}

\newenvironment{readbody}{\list{}{
  \itemindent=-1cm
  \leftmargin=1cm
  \parsep=0pt}
  \obeylines\alterfont}{\endlist}

\begin{document}
\begin{readbody}
\sv Señor, enséñame tus caminos,
    instrúyeme en tus sendas: 
    haz que camine con lealtad;
    enséñame, porque tú eres mi Dios y Salvador. \sr

\sv Recuerda, Señor, que tu ternura
    y tu misericordia son eternas;
    acuérdate de mí con misericordia,
    por tu bondad, Señor. \sr                        

\sv El Señor es bueno y es recto,
    enseña el camino a los pecadores;
    hace caminar a los humilles con rectitud,
    enseña su camino a los humildes. \sr
\end{readbody}

\end{document}
0

You must log in to answer this question.

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