Re: Calcul de longueur d'un texte

Liste des GroupesRevenir à fct tex 
Sujet : Re: Calcul de longueur d'un texte
De : projetmbc (at) *nospam* gmail.com (projetmbc)
Groupes : fr.comp.text.tex
Date : 24. Oct 2022, 13:32:14
Autres entêtes
Message-ID : <910a0f84-f979-4502-b0c6-c6fcad6937a0n@googlegroups.com>
References : 1 2 3 4
User-Agent : G2/1.0
Le lundi 24 octobre 2022 à 13:29:03 UTC+2, Denis Bitouzé a écrit :
Le 24/10/22 à 04h23, projetmbc a écrit :
 
Merci Denis.
 
Padkoi.
Ce que je voulais obtenir est ce qui suit.
 
--8<---------------cut here---------------start------------->8---
\newcommand\rulerstest[2][4cm]{
\null\hfill\raisebox{2pt}{\rule{#1}{2pt}}\textbf{\,#2\,}\raisebox{2pt}{\rule{#1}{2pt}}\hfill\null
 
\blabla
 
\null\hfill\raisebox{2pt}{\rule{#1*2+\widthof{\textbf{\,#2\,}}}{2pt}}\hfill\null
}
--8<---------------cut here---------------end--------------->8---
Et ça a donc l'effet escompté ?
--
Denis
Oui. Voici un fichier test.

 --8<---------------cut here---------------start------------->8---
\documentclass{article}

\usepackage{calc}

\newcommand\blabla{
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
}

\newcommand\rulerstest[2][4cm]{
\null\hfill\raisebox{2pt}{\rule{#1}{2pt}}\textbf{\,#2\,}\raisebox{2pt}{\rule{#1}{2pt}}\hfill\null

\blabla

% Indication donné par D. Bitouzé sur fr.comp.text.tex .
\null\hfill\raisebox{2pt}{\rule{#1*2+\widthof{\textbf{\,#2\,}}}{2pt}}\hfill\null
}


\begin{document}


\rulerstest{Titre court}

\bigskip

\rulerstest{Titre trop long}

\bigskip

\rulerstest{Titre trop, trop, trop long}

\bigskip

\rulerstest[3cm]{Titre trop, trop, trop long}

\end{document}
--8<---------------cut here---------------end--------------->8---

Date Sujet#  Auteur
24 Oct 22 * Calcul de longueur d'un texte6projetmbc
24 Oct 22 +- Re: Calcul de longueur d'un texte1projetmbc
24 Oct 22 `* Re: Calcul de longueur d'un texte4Denis Bitouzé
24 Oct 22  `* Re: Calcul de longueur d'un texte3projetmbc
24 Oct 22   `* Re: Calcul de longueur d'un texte2Denis Bitouzé
24 Oct 22    `- Re: Calcul de longueur d'un texte1projetmbc

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal