Text FormattingIndent with Flushright

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
jaybz
Posts: 90
Joined: Sun Jul 11, 2010 6:02 pm

Indent with Flushright

Post by jaybz »

How can I get this first line of this to indent and still be flushedright to the margin? indent doesn't seam to work.

Code: Select all

\documentclass[10pt,a4paper,english]{article}
\usepackage[left=27mm,top=14mm,bottom=14mm,right=29mm,
            nohead,nofoot]{geometry}
\usepackage{mathtools}
\begin{document}
\begin{small}
\begin{flushright}
\indent We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable rights.  \linebreak
text. (That to secure these rights, governments are instituted among men.)
\end{flushright}
\end{document}
Last edited by jaybz on Thu Apr 28, 2011 10:02 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: Indent with Flushright

Post by localghost »

Where is the sense in indenting some text explicitly that is flushed to the right? Put some text before the flushed part to see what I mean.


Thorsten
jaybz
Posts: 90
Joined: Sun Jul 11, 2010 6:02 pm

Indent with Flushright

Post by jaybz »

This is what I would like. The math content should be centered to the first and second lines. Maybe a multi-column envir. or package that allows me to write in the margin?

Maybe


Edit by localghost: Preferably no external links (see Board Rules, Section 2.5). Attachments go onto the forum server where possible.
Attachments
The desired result.
The desired result.
flushed-example.png (87.78 KiB) Viewed 5726 times
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Indent with Flushright

Post by localghost »

Why not use a list environment (description) customized by enumitem? Or a table? Somehow you have already produced this output. What keeps you from using it? I remember that I provided the code for the aligned math expression.
jaybz
Posts: 90
Joined: Sun Jul 11, 2010 6:02 pm

Re: Indent with Flushright

Post by jaybz »

Sorry about the link. I created the example with a combination of Latex and Scribus. But it's time consuming to do because I'm creating the math part with Latex then converting it to postscript with pdftops then importing it into Scribus. Also for some weird reason the word "and" in the math was not in the conversion so I had to add it with Scribus. I had been using pdf2ps for other files but the output was poor quality and I tried it for this math piece but it only produces a blank page.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Indent with Flushright

Post by localghost »

The output as shown in the picture is quite easy to do. But we will get away from the package solution in favor of a short exercise about custom lists. I think this will help in the future.

I remembered that I once created a new »xlist« environment (of course you are free to name it like you want) for cases where enumitem is not so helpful. The code below introduces this environment with slight modifications.

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{geometry}
\usepackage{mathtools}

\newenvironment{xlist}{%
  \begin{list}{}{%
    \setlength{\labelwidth}{5em}
    \setlength{\labelsep}{1em}
    \setlength{\leftmargin}{\labelwidth}
    \addtolength{\leftmargin}{\labelsep}
    \setlength{\rightmargin}{0pt}
    \setlength{\parsep}{0.5ex plus 0.2ex minus 0.1ex}
    \setlength{\itemsep}{0.3ex plus 0.2ex}
    \renewcommand{\makelabel}[1]{\textsf{##1}\hfil}
  }
}
{\end{list}}

\begin{document}
  \begin{xlist}
    \item[Example 1] This is the first line of text here in the document.
    \item[Solution] This is the next line of text here in the document which extends to the right margin when wrapped to the next line.

      \medskip
      We have the following
      \begin{alignat*}{2}
        2x &= 4x^{2}+7x       &\makebox[10em]{and} g(x) &= 42 \\
        2x &= 4x^{2}+7x       & g'(x) &= 12 \\
        2x &= \tan(x)x^{2}+7x & g''(x) &= 7x +1
      \end{alignat*}
  \end{xlist}
\end{document}
I suggest to play around a little bit with the list parameters just to get familiar with them. If you have access to book about LaTeX basics, you should find detailed explanation there.
jaybz
Posts: 90
Joined: Sun Jul 11, 2010 6:02 pm

Indent with Flushright

Post by jaybz »

Thank you I'll experiment with that. I also found a pretty good page talking about making your own lists.
http://www.troubleshooters.com/linux/lyx/ownlists.htm
Post Reply