5

Some of you may know the FlipBeamertheme by Phillip Tanedo (http://www.physics.uci.edu/~tanedo/files/code/FlipBeamerTemplate.pdf)

I like the style of it's title. Tanedo used a picture:

enter image description here

All three lines are adjusted on both sides. I assume Tanedo had to play around a while with font sizes, kerning and word spacing to achieve this.

Now I'm wondering if one could achieve that effect "automatically" with xelatex or lualatex.

Something like an environment which calculates the needed font size and then for fine adjusting the word spacing.

7

A solution with adjustable features:

\documentclass{article}
\usepackage{fontspec}
\usepackage{graphicx}
\usepackage{xparse}

\setsansfont{Gill Sans}

\ExplSyntaxOn
\NewDocumentCommand{\tanedo}{O{}m}
 {% do everything in a group not to clobber previous values
  \group_begin:
  % evaluate the keys in the optional argument
  \keys_set:nn { schmendrich/tanedo } { #1 }
  % pass control of typesetting to an internal function
  \schmendrich_tanedo:n { #2 }
  % close the group
  \group_end:
 }

% define the needed keys
\keys_define:nn { schmendrich/tanedo }
 {
  width .dim_set:N = \l_schmendrich_title_width_dim,
  skip  .dim_set:N = \l_schmendrich_title_skip_dim,
  skip  .initial:n = { 3pt },
  font  .tl_set:N  = \l_schmendrich_title_font_tl
 }

% a couple of needed variables
\seq_new:N \l_schmendrich_input_title_seq
\box_new:N \l_schmendrich_line_box

% the main function
\cs_new_protected:Npn \schmendrich_tanedo:n #1
 {
  % split the title argument into pieces at \\
  \seq_set_split:Nnn \l_schmendrich_input_title_seq { \\ } { #1 }
  % if no required width has been specified, determine the natural width
  % (the signal for this is the width variable is still 0pt
  \dim_compare:nT { \l_schmendrich_title_width_dim = 0pt }
   {
    \seq_map_inline:Nn \l_schmendrich_input_title_seq
     {% put the item in a box applying the chosen font
      \hbox_set:Nn \l_schmendrich_line_box { \tl_use:N \l_schmendrich_title_font_tl ##1 }
      % compare the width of the box with the last stored width value
      \dim_compare:nT { \l_schmendrich_title_width_dim < \box_wd:N \l_schmendrich_line_box }
       {% if the stored value is less than the current one, set accordingly
        \dim_set:Nn \l_schmendrich_title_width_dim { \box_wd:N \l_schmendrich_line_box }
       }
     }
   }
  % we do it in a minipage as wide as necessary
  \begin{minipage}{\l_schmendrich_title_width_dim}
  % some low level trickery
  \lineskiplimit=\c_max_dim % two lines will always be too near
  \lineskip = \l_schmendrich_title_skip_dim % so \lineskip will be used
  % apply \centering (not strictly necessary, though)
  \centering
  % set the font
  \tl_use:N \l_schmendrich_title_font_tl
  % typeset each line in a suitable \resizebox
  \seq_map_inline:Nn \l_schmendrich_input_title_seq
   {
    \resizebox{\l_schmendrich_title_width_dim}{!}{##1} \\
   }
  % finish off
  \end{minipage}
 }
\ExplSyntaxOff

\begin{document}

\sffamily

\tanedo{THIS IS A \\ SAMPLE \\ TALK TITLE}

\bigskip

\tanedo[font=\bfseries]{THIS IS A \\ SAMPLE \\ TALK TITLE}

\bigskip

\tanedo[width=5cm]{THIS IS A \\ SAMPLE \\ TALK TITLE}

\bigskip

\tanedo[width=5cm,skip=6pt,font=\bfseries]{THIS IS A \\ SAMPLE \\ TALK TITLE}

\end{document}

If no width is specified, then the lines are measured at their natural size and the widest line will be used for resizing the others. You can also adjust the skip between lines (default 3pt) and set font attributes.

Each line is set in a \resizebox with the appropriate width by means of \seq_map_inline:Nn that processes each line, previously stored with \seq_set_split:Nnn.

The same idea is used for computing the natural width when the width option is not specified.

enter image description here

  • Wow this is great. Unfortunately I don't understand a word of the macro's construction. But this is up to me. I think i will make it a package to have it at hand easily. Thank you very much. – schmendrich Mar 16 '15 at 11:14
  • 1
    @schmendrich I added some comments to the code – egreg Mar 16 '15 at 11:22
6

With adjustbox.

\documentclass{article}
\usepackage{adjustbox}


\begin{document}
\noindent
\adjustbox{width=15mm,height=1.5ex}{THIS IS A}\\
\adjustbox{width=15mm,height=1.5ex}{SAMPLE}\\
\adjustbox{width=15mm,height=1.5ex}{TALK LITTLE}

\end{document}

enter image description here

This can be done with \resizebox also.

\documentclass{article}
\usepackage{graphicx}


\begin{document}
\noindent
\resizebox{15mm}{1.5ex}{THIS IS A}\\
\resizebox{15mm}{1.5ex}{SAMPLE}\\
\resizebox{15mm}{1.5ex}{TALK LITTLE}

\end{document}
  • That easy? I like your solution for it's simplicity. I'll keep that in mind, for days when I don't have egregs solution at hand. Thank you very much. – schmendrich Mar 16 '15 at 11:10
  • 1
    @schmendrich Easy because it is raw :-) – user11232 Mar 16 '15 at 13:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.