TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In a style file for thesis and dissertations in LaTeX, for my school, certain sections have green boxes. Those sections are abstract, acknowledgements, dedication, and citation. Is there a way to have words shifted according to length?

enter image description here

enter image description here

Abstract looks okay but Acknowledgements stick out on the right too much. Is it possible to have LaTeX determine based on word length how to shift the title?

In the style file, the environments are set up:

% abstract environment                                                            
  \begin{tikzpicture}[remember picture, overlay]%                                 
    \pgftext[right, x = 12cm, y = 0.2cm]{                                         
      \color{uvmgreen}\Huge\bfseries Abstract};%                                  
    \draw[fill = uvmgreen, draw = uvmgreen] (15.5,-.75) rectangle (10,1);%        
    \clip (15.5,-.75) rectangle (10,1);                                           
    \pgftext[right, x = 12cm, y = 0.2cm]{                                         
      \color{white}\Huge\bfseries Abstract};%                                     



% acknowledgements environment                                                    
  \begin{tikzpicture}[remember picture, overlay]%                                 
    \pgftext[right, x = 12cm, y = 0.2cm]{                                         
      \color{uvmgreen}\Huge\bfseries Acknowled\smash{g}ements};%                  
    \draw[fill = uvmgreen, draw = uvmgreen] (15.5,-.75) rectangle (10,1);%        
    \clip (15.5,-.75) rectangle (10,1);                                           
    \pgftext[right, x = 12cm, y = 0.2cm]{                                         
      \color{white}\Huge\bfseries Acknowled\smash{g}ements};%                     

share|improve this question
Why are you using \pgftext instead of \node? What do you mean with “stick out on the right too much”? It looks like both Abstract and Acknowledgments are pretty much the same length in the green box. And what do you want to shift about what length? Is there a reason you are using remember picture (with no coordinates/nodes) and overlay? – Qrrbrbirlbel Dec 13 '13 at 21:44
You want box to start from the middle of the word?, Till what point on the right, the box and text should reach? Why not a complete MWE? – Harish Kumar Dec 13 '13 at 23:07
@HarishKumar the middle would be fine. Is there a way to set this automated with added environments. – dustin Dec 14 '13 at 0:42
@Qrrbrbirlbel this isn't my code. It is a style file for preparing a thesis but I don't like the look. By right, I meant to say left. – dustin Dec 14 '13 at 0:44
How long the box would stretch to the right? – Harish Kumar Dec 14 '13 at 0:51
up vote 4 down vote accepted

Your question or submission doesn't really have clear specification.

The green box starts at the middle of the text, and its length is the half of the text (with the addition of the length named \rightpadding).

enter image description here






\tikzstyle{every node}=[minimum height=30pt, inner sep=0pt, font=\Large\bfseries]%
    \begin{tikzpicture}\node {#1};\end{tikzpicture}%
        \clip[minimum width=\rightwidth] (\leftwidth,-30pt) rectangle (\width,0pt);
        \fill[color=darkgreen] (\leftwidth,-30pt) rectangle (\width,0pt)
            node[color=white] at (\leftwidth,-15pt) {#1};
        \clip[minimum width=\leftwidth] (0,-30pt) rectangle (\leftwidth,0pt);
        \draw[draw=none] (0,-30pt) rectangle (\the\wd\mybox,0pt)
            node[color=darkgreen] at (\leftwidth,-15pt) {#1};




share|improve this answer
Can you right align them and make the green boxes the same length? The only piece being adjusted should be word placement. – dustin Dec 14 '13 at 16:21
@dustin just add a \hfill before the \begin{tikzpicture} (and I have removed the [overlay] modifiers, because they weren't needed) – masu Dec 14 '13 at 17:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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