Ich möchte den den String "/t" zb. 33 Mal hintereinander schreiben... /t/t/t/usw. Wie geht das im Latex?

gefragt 08 Sep '14, 12:08

Jeff's gravatar image

Jeff
51123
Akzeptiert-Rate: 0%

bearbeitet 08 Sep '14, 12:08

Nur zur Info: einen „String“, wie ihn andere Programmiersprachen kennen, gibt es in (La)TeX nicht.

(08 Sep '14, 19:37) cgnieder

Du kannst die Ausgabe über eine Schleife vornehmen. Dafür gibt es verschiedene Möglichkeiten. Hier sind mal drei Beispiele:

Mit \foreach

Open in writeLaTeX
Code, hier editierbar zum Übersetzen:
\documentclass{scrartcl}
\usepackage{pgffor}
\begin{document}
\foreach \i in {1,...,33}{/t}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Mit \multido

Open in writeLaTeX
Code, hier editierbar zum Übersetzen:
\documentclass{scrartcl}
\usepackage{multido}
\begin{document}
\multido{}{33}{/t}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Mit \whiledo

Open in writeLaTeX
Code, hier editierbar zum Übersetzen:
\documentclass{scrartcl}
\usepackage{ifthen}
\newcounter{zaehler}
\begin{document}
\setcounter{zaehler}{0}
\whiledo{\value{zaehler}<33}{%
/t%
\stepcounter{zaehler}%
}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Permanenter link

beantwortet 08 Sep '14, 12:49

esdd's gravatar image

esdd
17.8k284257
Akzeptiert-Rate: 62%

bearbeitet 08 Sep '14, 15:23

Als Alternative zu Elkes Antwort hier vier weitere Möglichkeiten, die ersten drei nur mit LaTeX2e-Bordmitteln, die vierte mit expl3. Wenn Zu den einzelnen Varianten weitere Erklärungen gewünscht sind, reiche ich die gerne nach.

Open in writeLaTeX
Code, hier editierbar zum Übersetzen:
\documentclass{article}
\usepackage{expl3,xparse}
% nur LaTeX2e:
\makeatletter
\newcounter{tmp}
% nicht expandierbar:
\newcommand\verfielfacheA[2]{%
\setcounter{tmp}{#1}%
\ifnum\value{tmp}>0
#2%
\addtocounter{tmp}{-1}%
\expandafter\@firstofone
\else
\expandafter\@gobble
\fi
{\verfielfacheA{\value{tmp}}{#2}}%
}
% nicht expandierbar:
\newcommand\verfielfacheB[2]{%
\setcounter{tmp}{#1}%
\@whilenum{\value{tmp}>0}\do{#2\addtocounter{tmp}{-1}}%
}
% expandierbar:
\newcommand\verfielfacheC[2]{%
\ifnum#1>0
\expandafter\@firstofone
\else
\expandafter\@gobble
\fi
{#2\expandafter\verfielfacheC\expandafter{\the\numexpr#1-1\relax}{#2}}%
}
\makeatother
% mit expl3 und xparse, expandierbar:
\ExplSyntaxOn
\cs_new:Npn \jeff_multiplicate:nn #1#2
{ \prg_replicate:nn {#1} {#2} }
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Permanenter link

beantwortet 08 Sep '14, 15:18

cgnieder's gravatar image

cgnieder
22.1k253463
Akzeptiert-Rate: 60%

bearbeitet 08 Sep '14, 15:19

Plain TeX

Hier wird \loop ... \if... ... \else ... \repeat verwendet. Siehe TeX by Topic S. 118 für Details.

Open in writeLaTeX
Code, hier editierbar zum Übersetzen:
\newcount\printcount
\def\multiprint#1#2{
\printcount=0
\loop\ifnum\printcount<#1
#2%
\advance\printcount by 1\repeat
}
\multiprint{33}{/t}
\bye
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Permanenter link

beantwortet 08 Sep '14, 17:48

Henri's gravatar image

Henri
15.7k133943
Akzeptiert-Rate: 46%

Deine Antwort
[Vorschau ausblenden]

Folgen dieser Frage

Per E-Mail:

Wenn sie sich anmelden, kommen Sie für alle Updates hier in Frage

Per RSS:

Antworten

Antworten und Kommentare

Frage-Themen:

×5

gestellte Frage: 08 Sep '14, 12:08

Frage wurde gesehen: 9,524 Mal

zuletzt geändert: 08 Sep '14, 19:37

Willkommen, erstes Mal hier? Schau mal unter FAQ!

×