Suite à la suggestion de Denis, pour reprendre la question Verbatim éditable, mais de façon plus large et plus générale. Comment récupérer un texte, avec sa mise en forme (saut de ligne, indentation, etc ) mais conserver la capacité de l'éditer localement, pour amender juste quelques parties ? Avec aussi la possibilité d'avoir dans le texte des caractères éventuellement interprété par latex ($,_, etc ..) Un exemple pratique (parmi d'autres) : récupération du texte d'une console, avec les commandes utilisées et les messages du système en réponse à ces commandes, conserver la mise en forme générale et pouvoir mettre en valeur les commandes utilisées Posée 29 Jui '19, 17:38 idefix |
Votre question est une question XY (https://texnique.fr/osqa/faq/#custom-id-xyz ). Au lieu de modifiez le texte vous-même, laissez l'extension Ouvrir dans l'éditeur Overleaf
\documentclass[a4paper,10pt,landscape]{article} \usepackage{listings} \usepackage{xcolor} \usepackage{geometry} \geometry{hmargin=0.5cm,vmargin=1.5cm} \lstdefinestyle{mystyle}{% basicstyle=\ttfamily, columns=fullflexible, breaklines, moredelim=[s][\color{red}]{dfqsdf}{$}, moredelim=[is][emphstyle]{|>}{<|},% emphstyle=\color{blue} } \lstset{style=mystyle} \begin{document} \begin{lstlisting} dfqsdf@Dominique-PC:~$ |>lsb_release -a<| No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.2 LTS Release: 18.04 Codename: bionic dfqsdf@Dominique-PC:~$ |>sudo apt update<| Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease Get:2 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB] ... Get:24 http://archive.ubuntu.com/ubuntu bionic-backports/universe Translation-en [1696 B] Fetched 17.6 MB in 14s (1271 kB/s) Reading package lists... Done Building dependency tree Reading state information... Done 66 packages can be upgraded. Run 'apt list --upgradable' to see them. dfqsdf@Dominique-PC:~$ |>apt list --upgradable<| Listing... Done apt/bionic-updates 1.6.11 amd64 [upgradable from: 1.6.10] apt-utils/bionic-updates 1.6.11 amd64 [upgradable from: 1.6.10] bind9-host/bionic-updates,bionic-security 1:9.11.3+dfsg-1ubuntu1.8 amd64 [upgradable from: 1:9.11.3+dfsg-1ubuntu1.7] bzip2/bionic-updates,bionic-security 1.0.6-8.1ubuntu0.1 amd64 [upgradable from: 1.0.6-8.1] .... xxd/bionic-updates,bionic-security 2:8.0.1453-1ubuntu1.1 amd64 [upgradable from: 2:8.0.1453-1ubuntu1] dfqsdf@Dominique-PC:~$ |>sudo apt-get install texlive-full<| Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: adwaita-icon-theme aglfn asymptote asymptote-doc at-spi2-core biber blt chktex cm-super cm-super-minimal context context-modules cpp cpp-7 dconf-gsettings-backend dconf-service dvidvi dvipng emacsen-common feynmf fontconfig fontconfig-config fonts-adf-accanthis fonts-adf-berenis fonts-adf-gillius fonts-adf-universalis fonts-arphic-bkai00mp fonts-arphic-bsmi00lp fonts-arphic-gbsn00lp fonts-arphic-gkai00mp fonts-baekmuk fonts-cabin ... Get:554 http://archive.ubuntu.com/ubuntu bionic/main amd64 zip amd64 3.0-11build1 [167 kB] Get:555 http://archive.ubuntu.com/ubuntu bionic/main amd64 libauthen-sasl-perl all 2.1600-1 [48.7 kB] Fetched 2560 MB in 1h 6min 48s (639 kB/s) Extracting templates from packages: 100% Preconfiguring packages ... Selecting previously unselected package fonts-dejavu-core. (Reading database ... 28645 files and directories currently installed.) Preparing to unpack .../00-fonts-dejavu-core_2.37-1_all.deb ... Unpacking fonts-dejavu-core (2.37-1) ... Selecting previously unselected package fontconfig-config. Preparing to unpack .../01-fontconfig-config_2.12.6-0ubuntu2_all.deb ... Unpacking fontconfig-config (2.12.6-0ubuntu2) ... .... Selecting previously unselected package zathura. Preparing to unpack .../445-zathura_0.3.8-1_amd64.deb ... Unpacking zathura (0.3.8-1) ... Selecting previously unselected package zip. Preparing to unpack .../446-zip_3.0-11build1_amd64.deb ... Unpacking zip (3.0-11build1) ... Selecting previously unselected package libauthen-sasl-perl. Preparing to unpack .../447-libauthen-sasl-perl_2.1600-1_all.deb ... Unpacking libauthen-sasl-perl (2.1600-1) ... Setting up libgs9-common (9.26~dfsg+0-0ubuntu0.18.04.9) ... Setting up libregexp-common-perl (2017060201-1) ... .... Setting up latex-cjk-chinese-arphic-gbsn00lp (1.23) ... update-language: texlive-base not installed and configured, doing nothing! Regenerating '/var/lib/texmf/fmtutil.cnf-DEBIAN'... done. Regenerating '/var/lib/texmf/fmtutil.cnf-TEXLIVEDIST'... done. update-fmtutil has updated the following file(s): /var/lib/texmf/fmtutil.cnf-DEBIAN /var/lib/texmf/fmtutil.cnf-TEXLIVEDIST If you want to activate the changes in the above file(s), you should run fmtutil-sys or fmtutil. Setting up fonts-font-awesome (4.7.0~dfsg-3) ... .... Checking for services that may need to be restarted...done. Checking for services that may need to be restarted...done. Checking init scripts... Restarting services possibly affected by the upgrade: invoke-rc.d: could not determine current runlevel Services restarted successfully. Setting up libatk1.0-0:amd64 (2.28.1-1) ... Setting up asymptote-doc (2.41-4) ... ... Setting up imagemagick-6.q16 (8:6.9.7.4+dfsg-16ubuntu6.7) ... update-alternatives: using /usr/bin/compare-im6.q16 to provide /usr/bin/compare (compare) in auto mode update-alternatives: using /usr/bin/compare-im6.q16 to provide /usr/bin/compare-im6 (compare-im6) in auto mode update-alternatives: using /usr/bin/animate-im6.q16 to provide /usr/bin/animate (animate) in auto mode update-alternatives: using /usr/bin/animate-im6.q16 to provide /usr/bin/animate-im6 (animate-im6) in auto mode ... Setting up zathura (0.3.8-1) ... Setting up libxml-parser-perl (2.44-2build3) ... Setting up libxml-sax-expat-perl (0.40-2) ... update-perl-sax-parsers: Registering Perl SAX parser XML::SAX::Expat with priority 50... update-perl-sax-parsers: Updating overall Perl SAX parser modules info file... Replacing config file /etc/perl/XML/SAX/ParserDetails.ini with new version Setting up zathura-pdf-poppler (0.2.8-1) ... ... Running mtxrun --generate. This may take some time... done. Pregenerating ConTeXt MarkIV format. This may take some time... done. Setting up context-modules (20170613-2) ... Setting up texlive-full (2017.20180305-1) ... Processing triggers for tex-common (6.09) ... Running updmap-sys. This may take some time... done. Running mktexlsr /var/lib/texmf ... done. Building format(s) --all. This may take some time... done. Processing triggers for libc-bin (2.27-3ubuntu1) ... Processing triggers for sgml-base (1.29) ... Processing triggers for ureadahead (0.100.0-21) ... Processing triggers for systemd (237-3ubuntu10.21) ... Processing triggers for libgdk-pixbuf2.0-0:amd64 (2.36.11-2) ... dfqsdf@Dominique-PC:~$ \end{lstlisting} \end{document} Publiée 29 Jui '19, 19:10 samcarter |
J'ajouterais à la réponse de samcarter que, si j'ai bien compris, votre but ultime est de mettre en forme des commandes et ce qu'elles renvoient de façon semblable à ce que peut afficher un terminal. Pour cela, je recommande le package
Je n'ai pas le temps de détailler davantage et la mise en forme est sûrement améliorable mais je livre la chose telle quelle. Ouvrir dans l'éditeur Overleaf
\documentclass[french]{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{lmodern} \usepackage{tcolorbox} \usepackage[a4paper]{geometry} \usepackage{accsupp} \usepackage{upquote} \usepackage{babel} \tcbuselibrary{listingsutf8,skins,breakable} \colorlet{keyword}{red} \colorlet{keyword2}{teal} \lstset{% keywordstyle=\color{keyword}, keywordstyle=[2]\color{keyword2}, alsoletter={-_},% } \lstdefinelanguage{bash}[]{sh}% { morekeywords={% lsb_release,sudo,apt,update,list% },% morekeywords=[2]{% options a% }% } \tcbset{mylistingstyle/.style={% breakable, blank, listing only, listing options={% style=tcblatex, % language=bash, escapeinside={(*@}{@*)}, upquote=true, showstringspaces=false }, }% }% \newtcblisting{shellinput}[1][]{% mylistingstyle, after skip=0cm, listing options={% style=tcblatex, language=bash, escapeinside={(*@}{@*)}, upquote=true, showstringspaces=false }, every listing line={% \textcolor{blue}{% \ttfamily\bfseries% \BeginAccSupp{method=plain,ActualText={}}% dfqsdf@Dominique-PC: \$ \EndAccSupp{}% }% }, #1 } \newtcblisting{shelloutput}[1][]{% mylistingstyle, before skip=0cm, #1 } \begin{document} \begin{shellinput} lsb_release -a \end{shellinput} \begin{shelloutput} No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.2 LTS Release: 18.04 Codename: bionic \end{shelloutput} \begin{shellinput} sudo apt update \end{shellinput} \begin{shelloutput} Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease Get:2 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB] ... Get:24 http://archive.ubuntu.com/ubuntu bionic-backports/universe Translation-en [1696 B] Fetched 17.6 MB in 14s (1271 kB/s) Reading package lists... Done Building dependency tree Reading state information... Done 66 packages can be upgraded. Run 'apt list --upgradable' to see them. \end{shelloutput} \end{document} Publiée 30 Jui '19, 02:46 denis ♦♦ |
@denis Le markdown suivant fonctionne, mais le lien renvoie à la question, pas à sa réponse qu'est censé indiquer le lien (6919)
[Une façon peu efficace de le faire](https://texnique.fr/osqa/questions/6913/sortir-localement-de-verbatim-dans-verbatim/6919 / "Il y a de bien meilleures méthodes, mais lesquelles ?")
Une façon peu efficace de le faire