TransWikia.com

How to write a portion of text on the right only?

TeX - LaTeX Asked on June 30, 2021

I would like to receive some help for writing a block o text completely on the right, in the form as in the photo below. Thank you so much!
enter image description here

5 Answers

documentclass{article}
usepackage{tabularx}
begin{document}

begin{tabularx}{linewidth}{lX}
Some text here:&
  Lorem ipsum dolor sit amet, consectetuer adipiscing elit.  Donec
  hendrerit tempor tellus.  Donec pretium posuere tellus.  Proin quam
  nisl, tincidunt et, mattis eget, convallis nec, purus.  Cum sociis
  natoque penatibus et magnis dis parturient montes, nascetur
  ridiculus mus.  Nulla posuere.  vspace{2ex}

Some other text here :&
    Pellentesque dapibus suscipit ligula.  Donec posuere augue in
    quam.  Etiam vel tortor sodales tellus ultricies commodo.
    Suspendisse potenti.  Aenean in sem ac leo mollis blandit.  Donec
    neque quam, dignissim in, mollis nec, sagittis eu, wisi.
    Phasellus lacus. 
  end{tabularx}

  begin{tabularx}{linewidth}{lX}
Some text:&
  Lorem ipsum dolor sit amet, consectetuer adipiscing elit.  Donec
  hendrerit tempor tellus.  Donec pretium posuere tellus.  Proin quam
  nisl, tincidunt et, mattis eget, convallis nec, purus.  Cum sociis
  natoque penatibus et magnis dis parturient montes, nascetur
  ridiculus mus.  Nulla posuere.  Donec vitae dolor.  Nullam tristique
  diam non turpis.  Cras placerat accumsan nulla.  Nullam rutrum.  Nam
  vestibulum accumsan nisl.vspace{2ex}
  end{tabularx}

end{document}

Texte

Correct answer by gigiair on June 30, 2021

You can use hagindent and hangafter TeX primitives after the text is measured using setbox primitive:

defp #1: {par setbox0=hbox{#1: }hangafter=1hangindent=wd0 noindentbox0 }

p Sometext here: bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
                  bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
                  bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
                  bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla.

Answered by wipet on June 30, 2021

The following approach uses paracol to set a two-column environment with the left column containing only the heading.

enter image description here

documentclass{article}

usepackage{paracol,lipsum}

newlength{sometextheading}
newenvironment{sometext}[1]{%
  settowidth{sometextheading}{#1:}%
  setcolumnwidth{sometextheading}%
  par
  begin{paracol}{2}
    noindent #1:
    switchcolumn[1]noindentignorespaces
}{%
  end{paracol}
}

begin{document}

sloppy% Just for this example
Here is some text

begin{sometext}{Some text}
  lipsum[1]
end{sometext}

begin{sometext}{Some more text here}
  lipsum[2]
end{sometext}

begin{sometext}{Yet more text}
  lipsum[3-6]
end{sometext}

begin{sometext}{Some closing text}
  lipsum[7]
end{sometext}

end{document}

Answered by Werner on June 30, 2021

You can do that with a description environment, customised with enumitem. The interesting point is that the contents of an item can break across pages.

documentclass{book}
usepackage{enumitem}
usepackage{calc} 

begin{document}

begin{description}[font=normalfont, leftmargin=widthof {Some text here: } + labelsep]
  item[Some text here: ] Blah blah blah blah …… blah blah blah blah blah blah blah blah. 
  Blah blah blah blah …… blah.
end{description}
begin{description}[font=normalfont, leftmargin=widthof {Some other text here: }+labelsep]
  item[Some other text here: ] Blah blah blah blah …… blah blah blah blah blah blah blah blah. 
  Blah blah blah blah …… blah.
end{description}

end{document} 

enter image description here

Answered by Bernard on June 30, 2021

Here's a very simple solution: use itemize with your left hand text as your custom 'bullet symbol'. This doesn't require any packages, or much code, and it makes all right hand text aligned.

documentclass{article}
begin{document}

begin{itemize}
 item[Some text here:] Lorem ipsum dolor sit amet, consectetuer adipiscing elit.  Donec hendrerit tempor tellus.  Donec pretium posuere tellus.  Proin quam nisl, tincidunt et, mattis eget, convallis nec, purus.  Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.  Nulla posuere.  vspace{2ex}
 item[Some other text here:] Pellentesque dapibus suscipit ligula.  Donec posuere augue in quam.  Etiam vel tortor sodales tellus ultricies commodo. Suspendisse potenti.  Aenean in sem ac leo mollis blandit.  Donec neque quam, dignissim in, mollis nec, sagittis eu, wisi.  Phasellus lacus. 
end{itemize}
 
end{document}

output

Answered by guest on June 30, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP