Text FormattingA decorated quote command/environment ideas?

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
karlisrepsons
Posts: 50
Joined: Sat May 23, 2009 10:13 pm

A decorated quote command/environment ideas?

Post by karlisrepsons »

It would be great to have two big quotes around quotations, however, as far as I tried, nothing really good came.

Failure 1:

Code: Select all

\newcommand{\myquote}[1]{
    {\fontsize{38}{0}\selectfont{``}} #1 {\fontsize{38}{0}\selectfont{''}}
}
Philipp_Poll_quote.jpeg
Philipp_Poll_quote.jpeg (28.41 KiB) Viewed 7133 times
Failure 2:

Code: Select all

\newcommand{\myquote}[1]{
   \begin{center}
         \begin{tabular}{lp{0.8\textwidth}l}
            {\fontsize{38}{0}\selectfont{``}} & #1 & {\fontsize{38}{0}\selectfont{''}}
         \end{tabular}
   \end{center}
}
Also, if there is \begin{tabular}{lp{0.8\textwidth}b{1cm}} instead of \begin{tabular}{lp{0.8\textwidth}l}, still nothing changes and I'd like to know why...
Philipp_Poll_quote2.jpeg
Philipp_Poll_quote2.jpeg (25.47 KiB) Viewed 7133 times
Maybe someone has an idea?

Recommended reading 2024:

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

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

magicmoose
Posts: 90
Joined: Fri Nov 06, 2009 7:29 am

A decorated quote command/environment ideas?

Post by magicmoose »

Here are two messy examples - are they suitable?

Code: Select all

\newcommand{\myquote}[1]{
   \begin{center}
         \renewcommand\arraystretch{.1}
         \begin{tabular}{lp{0.8\textwidth}l}
            {\fontsize{38}{0}\selectfont{``}} & #1 & \\ & & {\fontsize{38}{0}\selectfont{''}}
         \end{tabular}
   \end{center}
}
or else;

Code: Select all

\newenvironment{myindentpar}[1]%
{\begin{list}{}%
     {\setlength{\leftmargin}{#1}}%
     \item[]%
}
{\end{list}}
(with thanks to gmedina) and then to use it:

Code: Select all

{\fontsize{38}{0}\selectfont{``}}\vspace{-23pt}
\begin{myindentpar}{1cm}
    [i]quote text[/i]
\end{myindentpar}
\vspace{-5pt} \hfill {\fontsize{38}{0}\selectfont{''}}
This may require some tweaking but the idea is there

Hope that has given you some ideas anyway
karlisrepsons
Posts: 50
Joined: Sat May 23, 2009 10:13 pm

A decorated quote command/environment ideas?

Post by karlisrepsons »

With some minor pains I obtained some hopeful result differently:

Code: Select all

\newcommand{\myquote}[1]{
   \newlength{\quotinglengthvar}
   \begin{center}
      \begin{tabular}{p{0pt}p{0.8\textwidth}b{0pt}}
         {
            \fontsize{38}{0}
            \selectfont
%                \setlength{\quotinglengthvar}{\heightof{``}}
            \settoheight{\quotinglengthvar}{``}
            \raisebox{-0.8\quotinglengthvar}{``}
         }
            & #1 &
            {
               \fontsize{38}{0}
               \selectfont
               \settoheight{\quotinglengthvar}{``}
               \raisebox{\quotinglengthvar}{''}
            }
      \end{tabular}\\
   {
      \fontsize{38}{0}
      \selectfont
      \settoheight{\quotinglengthvar}{``}
      \hfill\vspace{-2\quotinglengthvar}
   }
   \end{center}
}
Philipp_Poll_quote3.jpeg
Philipp_Poll_quote3.jpeg (27.52 KiB) Viewed 7122 times
It forces me to ask several questions, which I've gathered and now they need to be answered:

1. is there some good way to measure some length in {..}, but store the result available from outside? Similar to this:

Code: Select all

\newlength{\quotinglengthvar}
{
   \fontsize{38}{0}
   \selectfont
   \settoheight{\quotinglengthvar}{``}
}
That has caused problems also in other cases and I'd love to receive an answer!

2. How to make \begin{tabular}{p{0pt}p{0.8\textwidth}b{0pt}} (or similar) work?! That is - to align to the bottom of tabular?
3. How to measure the visible height of text instead of some mystic other height?
karlisrepsons
Posts: 50
Joined: Sat May 23, 2009 10:13 pm

A decorated quote command/environment ideas?

Post by karlisrepsons »

Thanks to Enrico Gregorio I have this pretty functional:
QuotesNEW.jpeg
QuotesNEW.jpeg (64.81 KiB) Viewed 7094 times

Code: Select all

\documentclass[a4paper]{article}
\usepackage{fontspec}
\usepackage{calc,lipsum}

\newcommand{\lowbiglquote}[1][70]{%
  \setbox0=\hbox{\fontsize{#1}{0}\selectfont``}%
  \setlength{\dimen0}{\ht0 - \heightof{A}}%
  \noindent\llap{\smash{\lower\dimen0\box0 }}}

\newcommand{\lowbigrquote}[1][70]{%
  \setbox0=\hbox{\fontsize{#1}{0}\selectfont''}%
  \setlength{\dimen0}{\ht0 - \heightof{A}}%
  \unskip\rlap{\smash{\lower\dimen0\box0 }}}

\begin{document}

\begin{quotation}
\lowbiglquote \lipsum[1]
Some text because lipsum ends a paragraph.\lowbigrquote
\end{quotation}

\end{document} 

Enrico Gregorio
> Cool! Thanks for a present!
> I just won't ask to explain everything about those commands, rather,
> could you recommend the books / papers I should read through to do
> things as easy as you did?

TeXbook, TeX by Topic for the primitive commands; and then comp.text.tex
and many package sources. :)

Let's see what \lowbiglquote does.

\newcommand{\lowbiglquote}[1][24]{%
Ê \sbox0{\fontsize{#1}{0}\selectfont``}%
Ê \setlength{\dimen0}{\ht0 - \heightof{A}}%
Ê \noindent\llap{\smash{\lower\dimen0\box0 }}}

The beginning is standard: one optional argument whose default value
is 24 (for the size of the quotes).

The "big" quotes are put into box register 0; actually saying
\sbox0{...} instead of \setbox0=\hbox{...} is better LaTeX programming,
although in this case there's no difference, since we don't change
colors inside the box.

The register's content is at our disposal for measuring it and also
for typesetting it in the future.

Indeed we use its height (\ht0) to set the scratch length register
\dimen0. Using the syntax provided by calc we subtract from it the
height of a capital letter in the current font. It would be the
same with the combination

Ê \setlength{\dimen0}{\ht0}%
\settoheight{\dimen2}{A}%
\addtolength{\dimen0}{-\dimen2}%

but with "calc" it's easier. Why this calculation? If we lower the
quotes by that amount, the top of the quotes will be aligned with the
top of the capital letters in the current font.

That's indeed what we do next: \noindent starts a paragraph with no
indentation; with \llap we set its argument in such a way that it
takes no space and protrudes to the left (the same can be obtained
with LaTeX's \makebox[0pt][r]{...}, but \llap is more efficient).

The box register containing the big quotes is lowered, but it is
also submitted to \smash, which annihilates its vertical dimension;
otherwise the box would push down the second line of the paragraph.

That's all. :)

Ciao
Enrico
The next cool option might be, if someone (maybe me later) would figure out how to place those big quotes within the parbox of text (not outside) and make text wrap around. I saw a similar example in one book some time ago. How we think, which variant would actually look better? Maybe those quotes are too big, who knows, is this better:
QuotesNEW2.jpeg
QuotesNEW2.jpeg (62.23 KiB) Viewed 7094 times
karlisrepsons
Posts: 50
Joined: Sat May 23, 2009 10:13 pm

A decorated quote command/environment ideas?

Post by karlisrepsons »

Even better:

Code: Select all

\newcommand{\lsidequotesize}{40}
\newcommand{\lsidequotecoeff}{0.325}
\definecolor{quotemarkcolor}{rgb}{0.5,0.5,0.5}

\newenvironment{lsidequote}{%
   \begin{quotation}%
      \setbox0=\hbox{\fontsize{\lsidequotesize}{0}\selectfont{\color{quotemarkcolor}``}}%
      \setlength{\dimen0}{\ht0 - \heightof{A}}%
      \noindent\llap{\smash{\lower\dimen0\box0}}%
}{%
   {%
      \newlength{\lastquoteheight}%
      \setbox0=\hbox{\fontsize{\lsidequotesize}{0}\selectfont{\color{quotemarkcolor}''}\setlength{\dimen0}{\heightof{''}}\global\lastquoteheight=\dimen0}%
      \setlength{\dimen0}{\ht0 - \lsidequotecoeff\lastquoteheight}%
      \unskip\hfill\llap{\smash{\lower\dimen0\box0\hskip\linewidth}}%
   }%
   \end{quotation}
}
QuotesNEW3.jpeg
QuotesNEW3.jpeg (33.21 KiB) Viewed 7075 times
It would look better, though, if there was more space between quotes and text. Problems again, if that is perceived as necessary.
By the way, can anyone post the definition of quotation environment?
Post Reply