# \#pretty-printing

**URL:** https://discourse.julialang.org/tag/pretty-printing/1140.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [Defining \`show\` method for all \`MIME\` types at once threw an error for \`display\`](https://discourse.julialang.org/t/defining-show-method-for-all-mime-types-at-once-threw-an-error-for-display/129790)

<div class="topic-metadata">

**Author:** [@frankwswang](https://discourse.julialang.org/u/frankwswang)\
**Replies:** 2\
**Last updated:** [June 10, 2025, 9:33pm UTC](https://discourse.julialang.org/t/defining-show-method-for-all-mime-types-at-once-threw-an-error-for-display/129790 "2025-06-10T21:33:44Z")

</div>

MWE (tested on Julia 1.11.5): julia\> struct MyT{T} a::T end julia\> import Base: show julia\> Base.show(io::IO, ::MIME, obj::MyT) = print(io, typeof(obj), "(...)") julia\> MyT(1) Error showing value of…

---

## [Printing vector of vectors with :compact output](https://discourse.julialang.org/t/printing-vector-of-vectors-with-compact-output/126515)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 7\
**Last updated:** [March 8, 2025, 10:00am UTC](https://discourse.julialang.org/t/printing-vector-of-vectors-with-compact-output/126515 "2025-03-08T10:00:23Z")

</div>

Following the docs example, we get matrices to be printed with the “compact” form of the elements: julia\> \[Polar(3, 4.0) Polar(4.0,5.3)\] 1×2 Matrix{Polar{Float64}}: 3.0ℯ4.0im 4.0ℯ5.3im and also with a dict with vecto…

---

## [Printing with nested indentation](https://discourse.julialang.org/t/printing-with-nested-indentation/122924)

<div class="topic-metadata">

**Author:** [@jules](https://discourse.julialang.org/u/jules)\
**Replies:** 3\
**Last updated:** [November 22, 2024, 9:30am UTC](https://discourse.julialang.org/t/printing-with-nested-indentation/122924 "2024-11-22T09:30:07Z")

</div>

Is there some generic reusable solution for the problem of printing nested objects with indentation? For example a custom show method for an array-like type where each item should be printed with an indent. But the items…

---

## [How to Automatically Generate Labels for \`ComposedFunction\`s in \`Plots.jl\`?](https://discourse.julialang.org/t/how-to-automatically-generate-labels-for-composedfunction-s-in-plots-jl/122702)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 1\
**Last updated:** [November 18, 2024, 7:40am UTC](https://discourse.julialang.org/t/how-to-automatically-generate-labels-for-composedfunction-s-in-plots-jl/122702 "2024-11-18T07:40:54Z")

</div>

I have the following code: using Plots f(x) = sin(x) plot(1:10, f.(1:10); label="$f") # This works as expected; the label is "f". g = f ∘ f plot(1:10, g.(1:10); label="$g") # The label here is "Main.f ∘ Main.f", but…

---

## [\[ANN\] NNParamsPrinter.jl - Quickly print the layers and weights of your Lux NNs](https://discourse.julialang.org/t/ann-nnparamsprinter-jl-quickly-print-the-layers-and-weights-of-your-lux-nns/121094)

<div class="topic-metadata">

**Author:** [@onedeeper](https://discourse.julialang.org/u/onedeeper)\
**Replies:** 3\
**Last updated:** [October 10, 2024, 7:35am UTC](https://discourse.julialang.org/t/ann-nnparamsprinter-jl-quickly-print-the-layers-and-weights-of-your-lux-nns/121094 "2024-10-10T07:35:54Z")

</div>

NNParamsPrinter.jl is a lightweight, simple printer of NN parameters. This is all it does. Please check the GitHub readme for usage. Why did I make this ? I wanted to quickly see the weights of a simple NN in a readabl…

---

## [\`print\` vs two-argument \`show\`/\`repr\` vs three-argument \`show\`/\`repr\` with \`MIME"text/plain"\`](https://discourse.julialang.org/t/print-vs-two-argument-show-repr-vs-three-argument-show-repr-with-mime-text-plain/117790)

<div class="topic-metadata">

**Author:** [@Krastanov](https://discourse.julialang.org/u/Krastanov)\
**Replies:** 5\
**Last updated:** [August 10, 2024, 12:45pm UTC](https://discourse.julialang.org/t/print-vs-two-argument-show-repr-vs-three-argument-show-repr-with-mime-text-plain/117790 "2024-08-10T12:45:51Z")

</div>

I asked this question some time ago on slack, posting now the answers here to avoid the slackhole of oblivion. Thanks to @jakobnissen, @Sukera, and @tecosaur for the information. Question When should I define methods…

---

## [How to change default number of digits printed for PrettyPrint](https://discourse.julialang.org/t/how-to-change-default-number-of-digits-printed-for-prettyprint/114463)

<div class="topic-metadata">

**Author:** [@freedomjin](https://discourse.julialang.org/u/freedomjin)\
**Replies:** 2\
**Last updated:** [May 20, 2024, 10:02pm UTC](https://discourse.julialang.org/t/how-to-change-default-number-of-digits-printed-for-prettyprint/114463 "2024-05-20T22:02:11Z")

</div>

Hi, I found PrettyPrint.jl quite handy when printing complex data structures, however, for large nested structures, pprint attempts to show all Float values to maximum precision and often overflows entire screen. Is it…

---

## [Array printing of custom objects](https://discourse.julialang.org/t/array-printing-of-custom-objects/111606)

<div class="topic-metadata">

**Author:** [@mdsalerno](https://discourse.julialang.org/u/mdsalerno)\
**Replies:** 1\
**Last updated:** [March 14, 2024, 10:02am UTC](https://discourse.julialang.org/t/array-printing-of-custom-objects/111606 "2024-03-14T10:02:08Z")

</div>

I defined the following object and show() methods: # Custom Set struct CustomSet{T} dict::Dict{T, Nothing} end CustomSet(xs) = CustomSet(Dict(zip(xs, fill(nothing, length(xs))))) # default show used by print func…

---

## [How to print elements of a matrix in LaTeX formatting?](https://discourse.julialang.org/t/how-to-print-elements-of-a-matrix-in-latex-formatting/111309)

<div class="topic-metadata">

**Author:** [@homocomputeris](https://discourse.julialang.org/u/homocomputeris)\
**Replies:** 4\
**Last updated:** [March 7, 2024, 5:02pm UTC](https://discourse.julialang.org/t/how-to-print-elements-of-a-matrix-in-latex-formatting/111309 "2024-03-07T17:02:07Z")

</div>

Given a matrix A = \[\[182740835762038560236502360265029360346025236045;; 2\]; \[328470287402983460892460286408129634;; 4\]\] I’d like to get LaTeX-formatted output, one element per line, e.g.: latexprint(A) A\_{1,1} = 18…

---

## [\[ANN\] Announcing AutoPrettyPrinting.jl](https://discourse.julialang.org/t/ann-announcing-autoprettyprinting-jl/109410)

<div class="topic-metadata">

**Author:** [@curtd](https://discourse.julialang.org/u/curtd)\
**Replies:** 8\
**Last updated:** [February 11, 2024, 2:13pm UTC](https://discourse.julialang.org/t/ann-announcing-autoprettyprinting-jl/109410 "2024-02-11T14:13:14Z")

</div>

Hey everyone. I’m happy to announce AutoPrettyPrinting.jl v0.1, which makes generating data-dependent pretty printing code a (relative) breeze. This package makes use of the excellent PrettyPrinting.jl, along with some s…

---

## [Make @with\_kw structure display with detail all its parameters](https://discourse.julialang.org/t/make-with-kw-structure-display-with-detail-all-its-parameters/109731)

<div class="topic-metadata">

**Author:** [@K5Julien](https://discourse.julialang.org/u/K5Julien)\
**Replies:** 4\
**Last updated:** [February 5, 2024, 10:09pm UTC](https://discourse.julialang.org/t/make-with-kw-structure-display-with-detail-all-its-parameters/109731 "2024-02-05T22:09:34Z")

</div>

Suppose that I use Parameters.jl and the following @with\_kw structure: using Parameters using Dates @with\_kw struct Params @deftype Int #PARAMETERS foo = 5 bar::Dict{String,Int} = Dict("a"=\>0,"b"=\>1) ti…

---

## [Nice printing of some values of an array](https://discourse.julialang.org/t/nice-printing-of-some-values-of-an-array/109512)

<div class="topic-metadata">

**Author:** [@Gravlax](https://discourse.julialang.org/u/Gravlax)\
**Replies:** 5\
**Last updated:** [January 31, 2024, 5:38pm UTC](https://discourse.julialang.org/t/nice-printing-of-some-values-of-an-array/109512 "2024-01-31T17:38:25Z")

</div>

During a simulation, it can be useful to monitor some representative values of an array (mean, max, min, median). With a colleague, we’ve tried to write a function or macro that prints the minimum and maximum value of a…

---

## [Port icecream from python?](https://discourse.julialang.org/t/port-icecream-from-python/105015)

<div class="topic-metadata">

**Author:** [@user664303](https://discourse.julialang.org/u/user664303)\
**Replies:** 3\
**Last updated:** [October 16, 2023, 2:48pm UTC](https://discourse.julialang.org/t/port-icecream-from-python/105015 "2023-10-16T14:48:05Z")

</div>

I recently came across a Python package called icecream. It allows for quick and easy printing of useful debug info. See the github page for some examples. You’ll also see (at the bottom) that it has been ported to a lar…

---

## [How Can I Display Meta-Data with PrettyTables in Julia?](https://discourse.julialang.org/t/how-can-i-display-meta-data-with-prettytables-in-julia/103310)

<div class="topic-metadata">

**Author:** [@Olegg](https://discourse.julialang.org/u/Olegg)\
**Replies:** 2\
**Last updated:** [August 28, 2023, 8:53pm UTC](https://discourse.julialang.org/t/how-can-i-display-meta-data-with-prettytables-in-julia/103310 "2023-08-28T20:53:51Z")

</div>

When using PrettyTables to display a DataFrame, eg with an HTML back-end, the size of the DataFrame is typically displayed at the top, as shown in the figure below. Is there a way to customize this to display some basic …

---

## [Avoid truncation for display of custom Tables object](https://discourse.julialang.org/t/avoid-truncation-for-display-of-custom-tables-object/101326)

<div class="topic-metadata">

**Author:** [@goerz](https://discourse.julialang.org/u/goerz)\
**Replies:** 0\
**Last updated:** [July 7, 2023, 7:07pm UTC](https://discourse.julialang.org/t/avoid-truncation-for-display-of-custom-tables-object/101326 "2023-07-07T19:07:29Z")

</div>

I have a custom type CollectedBenchmarks that implements the Tables.jl interface. I’ve defined function Base.show(io::IO, ::MIME"text/plain", b::CollectedBenchmarks) pretty\_table(io, b; show\_row\_number=true) end us…

---

## [Pretty Table does not display in Documenter.jl](https://discourse.julialang.org/t/pretty-table-does-not-display-in-documenter-jl/100065)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 6\
**Last updated:** [June 8, 2023, 7:53pm UTC](https://discourse.julialang.org/t/pretty-table-does-not-display-in-documenter-jl/100065 "2023-06-08T19:53:37Z")

</div>

I use PrettyTables to format the printing of structs. It works in the REPL, but not in my documentation. The problem occurs in the subsection called create model object. I was wondering if anyone might now why its not w…

---

## [Using a variable to format printf not allowed?](https://discourse.julialang.org/t/using-a-variable-to-format-printf-not-allowed/99200)

<div class="topic-metadata">

**Author:** [@mmv](https://discourse.julialang.org/u/mmv)\
**Replies:** 9\
**Last updated:** [May 23, 2023, 8:56am UTC](https://discourse.julialang.org/t/using-a-variable-to-format-printf-not-allowed/99200 "2023-05-23T08:56:07Z")

</div>

Hi! I’m trying to write a simple text file where each line follows one of a few specific formats. Is it not permitted to use a variable to specify the format for @printf? Example: julia\> fname = "abc" "abc" julia\> @pr…

---

## [Compact display of Floats with @show?](https://discourse.julialang.org/t/compact-display-of-floats-with-show/97554)

<div class="topic-metadata">

**Author:** [@Eben60](https://discourse.julialang.org/u/Eben60)\
**Replies:** 4\
**Last updated:** [May 21, 2023, 11:17am UTC](https://discourse.julialang.org/t/compact-display-of-floats-with-show/97554 "2023-05-21T11:17:25Z")

</div>

julia\> Base.active\_repl.options.iocontext\[:compact\]=true true julia\> e = exp(1) 2.71828 julia\> @show e; e = 2.718281828459045

---

## [MPI and println inside imported modules](https://discourse.julialang.org/t/mpi-and-println-inside-imported-modules/95026)

<div class="topic-metadata">

**Author:** [@mesonepigreco](https://discourse.julialang.org/u/mesonepigreco)\
**Replies:** 4\
**Last updated:** [February 22, 2023, 3:57pm UTC](https://discourse.julialang.org/t/mpi-and-println-inside-imported-modules/95026 "2023-02-22T15:57:48Z")

</div>

Dear Juliawers, I’m using optimizing a function in julia which is parallelized using MPI. Each time I have to print something, I check if the rank is zero to avoid printing the text as many times as the number of proce…

---

## [REPL crashes with custom pretty printing and Dictionaries](https://discourse.julialang.org/t/repl-crashes-with-custom-pretty-printing-and-dictionaries/87622)

<div class="topic-metadata">

**Author:** [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)\
**Replies:** 8\
**Last updated:** [September 23, 2022, 1:02pm UTC](https://discourse.julialang.org/t/repl-crashes-with-custom-pretty-printing-and-dictionaries/87622 "2022-09-23T13:02:07Z")

</div>

The REPL crashes when I run the following code twice, the first time giving the expected StackOverflowError: using Dictionaries: dictionary struct Bcode code::Int end Base.convert(::Type{String}, b::Bcode) = dicti…
